mirror of
https://github.com/mudler/LocalAI.git
synced 2024-12-23 22:42:27 +00:00
Fix lock handling
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
04550d83a6
commit
5ccc4f3ad6
@ -493,12 +493,16 @@ func handleVAD(session *Session, conversation *Conversation, c *websocket.Conn,
|
|||||||
log.Debug().Msgf("speech ends at %0.2fs", s.End)
|
log.Debug().Msgf("speech ends at %0.2fs", s.End)
|
||||||
speechEnd = s.End
|
speechEnd = s.End
|
||||||
} else {
|
} else {
|
||||||
log.Printf("speech is ongoing")
|
|
||||||
session.AudioBufferLock.Unlock()
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if speechEnd == 0 && speechStart != 0 {
|
||||||
|
session.AudioBufferLock.Unlock()
|
||||||
|
log.Debug().Msg("speech is ongoing")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Handle when input is too long without a voice activity (reset the buffer)
|
// Handle when input is too long without a voice activity (reset the buffer)
|
||||||
if speechStart == 0 && speechEnd == 0 {
|
if speechStart == 0 && speechEnd == 0 {
|
||||||
log.Debug().Msg("VAD detected no speech activity")
|
log.Debug().Msg("VAD detected no speech activity")
|
||||||
@ -531,9 +535,7 @@ func handleVAD(session *Session, conversation *Conversation, c *websocket.Conn,
|
|||||||
conversation.Lock.Unlock()
|
conversation.Lock.Unlock()
|
||||||
|
|
||||||
// Reset InputAudioBuffer
|
// Reset InputAudioBuffer
|
||||||
session.AudioBufferLock.Lock()
|
|
||||||
session.InputAudioBuffer = nil
|
session.InputAudioBuffer = nil
|
||||||
session.AudioBufferLock.Unlock()
|
|
||||||
|
|
||||||
// Send item.created event
|
// Send item.created event
|
||||||
sendEvent(c, OutgoingMessage{
|
sendEvent(c, OutgoingMessage{
|
||||||
|
Loading…
Reference in New Issue
Block a user