-
Notifications
You must be signed in to change notification settings - Fork 2
OpenAI speech detect #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fix error events not notified by module #17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements OpenAI speech detection functionality to track when OpenAI starts and stops speaking during audio streaming sessions. The implementation adds event-driven notifications for speech state changes to enable better handling of conversation flow and interruptions.
- Adds speech state tracking with
m_openai_speakingandm_response_audio_doneflags - Implements speech start/stop detection logic in the audio playback pipeline
- Introduces new event types for notifying external systems of speech state changes
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| openai_audio_streamer_glue.cpp | Core speech detection logic, state tracking, and event notification methods |
| mod_openai_audio_stream.h | Event constant definitions for speech start/stop notifications |
| mod_openai_audio_stream.c | Event registration and cleanup for new speech detection events |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| if (as->clear_requested()) { | ||
| switch_buffer_zero(tech_pvt->playback_buffer); | ||
| inuse = 0; |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting inuse = 0 after clearing the buffer could cause incorrect behavior. The inuse variable represents the actual bytes in the buffer, and after switch_buffer_zero() it should reflect the buffer's empty state, but this assignment might interfere with the subsequent logic that depends on the actual buffer size.
| inuse = 0; | |
| inuse = switch_buffer_inuse(tech_pvt->playback_buffer); |
| switch_buffer_write(tech_pvt->playback_buffer, chunk.data(), chunk.size() * sizeof(int16_t)); | ||
| } else if (inuse == 0) { | ||
| // Openai just finished speaking for interruption or end of response | ||
| if(as->is_openai_speaking() && as->is_response_audio_done()) { |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The condition combines two state checks that could be confusing. Consider adding a comment explaining when both conditions are true simultaneously, or create a helper method like should_stop_speech() to encapsulate this logic.
Signed-off-by: Dario Pellegrino <dario.pellegrino@voismart.it>
8bb818d to
57e8324
Compare
No description provided.