Browse Source

stop streaming play after get input audio.

lloydzhou 1 year ago
parent
commit
283caba8ce
1 changed files with 2 additions and 1 deletions
  1. 2 1
      app/components/realtime-chat/realtime-chat.tsx

+ 2 - 1
app/components/realtime-chat/realtime-chat.tsx

@@ -202,7 +202,6 @@ export function RealtimeChat({
   };
   };
 
 
   const handleInputAudio = async (item: RTInputAudioItem) => {
   const handleInputAudio = async (item: RTInputAudioItem) => {
-    audioHandlerRef.current?.stopStreamingPlayback();
     await item.waitForCompletion();
     await item.waitForCompletion();
     if (item.transcription) {
     if (item.transcription) {
       const userMessage = createMessage({
       const userMessage = createMessage({
@@ -226,6 +225,8 @@ export function RealtimeChat({
         });
         });
       });
       });
     }
     }
+    // stop streaming play after get input audio.
+    audioHandlerRef.current?.stopStreamingPlayback();
   };
   };
 
 
   const toggleRecording = async () => {
   const toggleRecording = async () => {