File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ export type VoiceContextType = {
80
80
callDurationTimestamp : string | null ;
81
81
toolStatusStore : ReturnType < typeof useToolStatus > [ 'store' ] ;
82
82
chatMetadata : Hume . empathicVoice . ChatMetadata | null ;
83
+ playerQueueLength : number ;
83
84
} ;
84
85
85
86
const VoiceContext = createContext < VoiceContextType | null > ( null ) ;
@@ -396,6 +397,7 @@ export const VoiceProvider: FC<VoiceProviderProps> = ({
396
397
callDurationTimestamp,
397
398
toolStatusStore : toolStatus . store ,
398
399
chatMetadata : messageStore . chatMetadata ,
400
+ playerQueueLength : player . queueLength ,
399
401
} ) satisfies VoiceContextType ,
400
402
[
401
403
connect ,
@@ -405,6 +407,7 @@ export const VoiceProvider: FC<VoiceProviderProps> = ({
405
407
player . isAudioMuted ,
406
408
player . muteAudio ,
407
409
player . unmuteAudio ,
410
+ player . queueLength ,
408
411
mic . fft ,
409
412
mic . isMuted ,
410
413
mic . mute ,
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ export const useSoundPlayer = (props: {
23
23
buffer : AudioBuffer ;
24
24
} >
25
25
> ( [ ] ) ;
26
+ const [ queueLength , setQueueLength ] = useState ( 0 ) ;
27
+
26
28
const isProcessing = useRef ( false ) ;
27
29
const currentlyPlayingAudioBuffer = useRef < AudioBufferSourceNode | null > (
28
30
null ,
@@ -36,6 +38,8 @@ export const useSoundPlayer = (props: {
36
38
onError . current = props . onError ;
37
39
38
40
const playNextClip = useCallback ( ( ) => {
41
+ setQueueLength ( clipQueue . current . length ) ;
42
+
39
43
if ( analyserNode . current === null || audioContext . current === null ) {
40
44
onError . current ( 'Audio environment is not initialized' ) ;
41
45
return ;
@@ -227,5 +231,6 @@ export const useSoundPlayer = (props: {
227
231
unmuteAudio,
228
232
stopAll,
229
233
clearQueue,
234
+ queueLength,
230
235
} ;
231
236
} ;
You can’t perform that action at this time.
0 commit comments