@@ -25,7 +25,7 @@ export async function unlockAudio() {
2525 if ( isAudioUnlocked ) {
2626 return ;
2727 }
28-
28+ console . log ( 'Unlocking audio context by playing silent audio' ) ;
2929 await ctx . resume ( ) ;
3030
3131 const buffer = ctx . createBuffer ( 1 , 1 , 22050 ) ;
@@ -35,13 +35,15 @@ export async function unlockAudio() {
3535 source . connect ( ctx . destination ) ;
3636 source . start ( 0 ) ;
3737 isAudioUnlocked = true ;
38+ console . log ( 'Audio context unlocked' ) ;
3839}
3940
4041export async function startStandByAudio ( ) {
42+ console . log ( 'Starting standby audio' ) ;
4143 const response = await fetch (
4244 loadFile ( 'plugins/AdminForthAgentPlugin/agentAudio/agent-processing.mp3' )
4345 ) ;
44-
46+ console . log ( 'Standby audio file loaded:, response:' , response ) ;
4547 const arrayBuffer = await response . arrayBuffer ( ) ;
4648 const audioBuffer = await ctx . decodeAudioData ( arrayBuffer ) ;
4749
@@ -50,7 +52,7 @@ export async function startStandByAudio() {
5052
5153 source . buffer = audioBuffer ;
5254 source . connect ( ctx . destination ) ;
53-
55+ console . log ( 'Playing standby audio' ) ;
5456 source . start ( ) ;
5557}
5658
@@ -81,6 +83,7 @@ export function playChatResponseCurrentChunks({
8183 playback : ChatResponseAudioPlayback ;
8284 chunks : ArrayBuffer [ ] ;
8385} ) {
86+ console . log ( 'Playing chat response audio chunks:' , chunks . length ) ;
8487 void ctx . resume ( ) . catch ( ( ) => undefined ) ;
8588
8689 for ( const chunk of chunks ) {
@@ -133,7 +136,7 @@ export function finishChatResponseAudio(playback: ChatResponseAudioPlayback | nu
133136 if ( ! playback || playback . isStopped ) {
134137 return ;
135138 }
136-
139+ console . log ( 'Finishing chat response audio playback' ) ;
137140 playback . isDone = true ;
138141
139142 if ( playback . pendingSourceCount === 0 ) {
@@ -145,7 +148,7 @@ export function stopChatResponseAudio(playback: ChatResponseAudioPlayback | null
145148 if ( ! playback || playback . isStopped ) {
146149 return ;
147150 }
148-
151+ console . log ( 'Stopping chat response audio playback' ) ;
149152 playback . isStopped = true ;
150153
151154 for ( const source of playback . activeSources ) {
@@ -207,6 +210,7 @@ function concatUint8Arrays(left: Uint8Array, right: Uint8Array) {
207210
208211export function endStandByAudio ( ) {
209212 if ( standbySource ) {
213+ console . log ( 'Ending standby audio' ) ;
210214 standbySource . stop ( ) ;
211215 standbySource = null ;
212216 }
0 commit comments