Skip to content

Commit

Permalink
Added new VAD, + code refactoring
Browse files Browse the repository at this point in the history
via https://raw.githubusercontent.com/Macoron/whisper.unity/275406258aca21fe7753cf0724a65f06fd464eea/Packages/com.whisper.unity/Runtime/Utils/AudioUtils.cs

thanks for the suggestion, yosun

also split AudioController into smaller separate classes for easier maintenance
  • Loading branch information
mapluisch committed Oct 16, 2024
1 parent 37459a1 commit 8aebf95
Show file tree
Hide file tree
Showing 15 changed files with 871 additions and 476 deletions.
140 changes: 139 additions & 1 deletion Assets/Prefabs/DemoIntegration.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,140 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &348816848496444118
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4243238183943022742}
- component: {fileID: 3953792458671070900}
- component: {fileID: 2621590784734090863}
m_Layer: 5
m_Name: VADEnergyText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4243238183943022742
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 348816848496444118}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5337751238952555557}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 868, y: -209.6}
m_SizeDelta: {x: 60, y: 32}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3953792458671070900
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 348816848496444118}
m_CullTransparentMesh: 1
--- !u!114 &2621590784734090863
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 348816848496444118}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294925056
m_fontColor: {r: 0, g: 0.35566974, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 12
m_fontSizeBase: 12
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 0
m_fontSizeMax: 0
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 0
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &725768174149704672
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2619,6 +2753,7 @@ RectTransform:
- {fileID: 9136329686101699382}
- {fileID: 3417785804709643581}
- {fileID: 9059768842823625612}
- {fileID: 4243238183943022742}
- {fileID: 5444497812387959711}
- {fileID: 2959617767447010246}
- {fileID: 5320398551607356139}
Expand Down Expand Up @@ -2647,9 +2782,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d24f73bbca3ae4c68b6ff8dde98d452c, type: 3}
m_Name:
m_EditorClassIdentifier:
audioController: {fileID: 0}
pushToTalkKey: 32
audioRecorder: {fileID: 0}
audioPlayer: {fileID: 0}
eventsText: {fileID: 4026597692773154623}
conversationText: {fileID: 2825327695736519003}
vadEnergyText: {fileID: 2621590784734090863}
pushToTalkButton: {fileID: 2178975479906841517}
connectButton: {fileID: 8428551282407799376}
pushToTalkButtonText: {fileID: 751159222626287672}
Expand Down
34 changes: 25 additions & 9 deletions Assets/Prefabs/RealtimeAPI.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ GameObject:
m_Component:
- component: {fileID: 6875561144310920953}
- component: {fileID: 7521549165741144525}
- component: {fileID: 68441443065667448}
- component: {fileID: 5778159951835551788}
- component: {fileID: 4277790966370773839}
m_Layer: 0
m_Name: AudioController
m_Name: Audio
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -129,7 +130,7 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &68441443065667448
--- !u!114 &5778159951835551788
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -138,15 +139,29 @@ MonoBehaviour:
m_GameObject: {fileID: 5144007666192891506}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9799235ff1b5f46148fca9921bdef04f, type: 3}
m_Script: {fileID: 11500000, guid: 158779b4cfa684eadbc49287121f2c45, type: 3}
m_Name:
m_EditorClassIdentifier:
listeningMode: 0
sampleRate: 24000
interruptResponseOnNewRecording: 1
vadThreshold: 0.1
vadSilenceDuration: 2
currentVolumeLevel: 0
interruptResponseOnNewRecording: 0
vadEnergyThreshold: 2
vadSilenceDuration: 1.5
vadFreqThreshold: 1
fftSampleSize: 1024
--- !u!114 &4277790966370773839
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5144007666192891506}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10dcd261ab0cf4839a08d9c49ec28b50, type: 3}
m_Name:
m_EditorClassIdentifier:
sampleRate: 24000
fftSampleSize: 1024
--- !u!1 &8086852912749008722
GameObject:
Expand Down Expand Up @@ -194,4 +209,5 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
apiKey:
audioController: {fileID: 68441443065667448}
audioPlayer: {fileID: 4277790966370773839}
audioRecorder: {fileID: 5778159951835551788}
41 changes: 28 additions & 13 deletions Assets/Scenes/DemoScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,6 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 5337751238952555557, guid: fc531736d51444c8280c8d93c32c7c33, type: 3}
m_PrefabInstance: {fileID: 6491429648409679553}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1157521912 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 68441443065667448, guid: 5ca84f8d7b82048e4ba92610cbf110e9, type: 3}
m_PrefabInstance: {fileID: 909518194653723852}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9799235ff1b5f46148fca9921bdef04f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1990000876
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -562,6 +551,28 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5ca84f8d7b82048e4ba92610cbf110e9, type: 3}
--- !u!114 &909518194653723853 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5778159951835551788, guid: 5ca84f8d7b82048e4ba92610cbf110e9, type: 3}
m_PrefabInstance: {fileID: 909518194653723852}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 158779b4cfa684eadbc49287121f2c45, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &909518194653723854 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 4277790966370773839, guid: 5ca84f8d7b82048e4ba92610cbf110e9, type: 3}
m_PrefabInstance: {fileID: 909518194653723852}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10dcd261ab0cf4839a08d9c49ec28b50, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &6491429648409679553
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -859,9 +870,13 @@ PrefabInstance:
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5488567229014774107, guid: fc531736d51444c8280c8d93c32c7c33, type: 3}
propertyPath: audioController
propertyPath: audioPlayer
value:
objectReference: {fileID: 909518194653723854}
- target: {fileID: 5488567229014774107, guid: fc531736d51444c8280c8d93c32c7c33, type: 3}
propertyPath: audioRecorder
value:
objectReference: {fileID: 1157521912}
objectReference: {fileID: 909518194653723853}
- target: {fileID: 5539276234762005852, guid: fc531736d51444c8280c8d93c32c7c33, type: 3}
propertyPath: m_AnchorMax.y
value: 0
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/Audio.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8aebf95

Please sign in to comment.