-
Notifications
You must be signed in to change notification settings - Fork 26
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
Make AudioPlayer queue global #484
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is great will get back to you once i had a chance to test it |
Deploying with
|
Latest commit: |
5ea0510
|
Status: | ✅ Deploy successful! |
Preview URL: | https://9d052ac7.console-overthinker-dev.pages.dev |
Branch Preview URL: | https://amnish04-global-audio-player.console-overthinker-dev.pages.dev |
There is a bug:when I record a new message it keeps talking while I'm recording a reply. It should stop immediately |
That's right, just pushed the fix! |
works awesome now. lets land |
tarasglek
approved these changes
Feb 26, 2024
kliu57
added a commit
that referenced
this pull request
Mar 4, 2024
created OpenAiProvider and OpenRouterProvider Make AudioPlayer queue global (#484) * Make audio player queue global and allow stopping tts * Pause immediately when another question is asked * Stop announcing messages as soon as tts is disabled * Reorder definitions * TTS should stop as soon as you start recording src/lib/ChatCraftProvider.ts fix
kliu57
added a commit
that referenced
this pull request
Mar 4, 2024
- Catch up with main - Make AudioPlayer queue global (#484)
kliu57
added a commit
that referenced
this pull request
Mar 4, 2024
- Catch up with main - Make AudioPlayer queue global (#484)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #357, I was able to stream audio responses as the LLM response was generated and also optimize the playback.
But there were some problems with it, and follow ups were filed.
This is regarding one of those follow ups - #391.
The problem was that once an audio clip was added to the audio queue, there was no way to stop it from other parts of the application since every invocation to
useAudioPlayer
hook resulted in a fresh audio queue. This was pretty annoying and made the TTS feature unusable as users had to wait for the previous message announcement to finish before it started playing for the next one.To fix this issue, I have made the Audio Player queue global, by creating and providing an
AudioPlayerContext
at the root of the application.https://github.com/tarasglek/chatcraft.org/compare/amnish04/global-audio-player?expand=1#diff-1cd8b18798a1a103bfe13bef54354c1f3a3bea29a31c8eea1a0c67a3a839b811
This allowed me to expose another function from the hook called
clearAudioQueue
which can now be called from any application component to pause the current audio clip, and flush the remaining clips in the queue.Currently, I am using it for 2 scenarios:
useAudioPlayer
will instantly stop as soon as the user disables the TTS setting.This approach also makes the audio system more robust any we now have a single source of truth for audio clips, and the risk to play multiple audio clips at once is also reduced.
This fixes #391