-
-
Notifications
You must be signed in to change notification settings - Fork 677
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
Proxy Handler triggered two times in StreamAudioSource #1195
Comments
See the instructions below:
|
I updated the issue. What I'm actually trying to do is request tts from Azure Open AI and the last part of the result is always cut. I gave you my full code, I will be disposing the api-key once this issue will be resolved. Help me please. thank you.. |
Before looking into your hypothesis, I am just looking at your implementation of class StreamSource extends StreamAudioSource {
StreamSource(this.stream);
final Stream<List<int>> stream;
@override
Future<StreamAudioResponse> request([int? start, int? end]) async {
return StreamAudioResponse(
sourceLength: null,
contentLength: null,
offset: null,
stream: stream,
contentType: 'audio/mpeg',
rangeRequestsSupported: false,
);
}
} An implementation should normally handle the case where multiple requests are made. I see in your bug report that you are mystified about why multiple requests would be made, but those requests are outside my control, they originate from the native player module (in this case, ExoPlayer). I also can't say I know why ExoPlayer is making multiple requests (particularly since you disabled range requests), but debug printing out the request headers might answer those questions. I am considering between whether that's just part of the mysterious behaviour of ExoPlayer which you need to adapt to, or whether somewhere in my code I am ignoring your request to disable range requests. |
I just feel that multiple requests is the problem but I'm not sure if it actually is. The actual problem is that the audio is not being played until the end. Few of the last chunks of the stream are not being played. If I may refer to my example code, I request Text to Speech request with the text that ends with "..... fine-tune custom models.", the audio is only played until "..... fine-tune custom mod"(this part is always different, sometimes it plays until the end, sometimes it even ends before this). I feel that this certainly is a bug/issue that needs to be fixed if my implementation is not wrong. I would be really grateful if you could look into this. I will also be playing around the library and comment if I find anything. Thank you so much! |
Can you reproduce this by downloading the response beforehand, saving it to a file, putting it in the assets directory and changing your stream audio source to read from that file stream? |
I haven't tried, but i think it will work fine if i download the file. I tested this in Postman and it was ok. |
In, iOS, the first few parts are lost. |
Same for me. On iOS audio playback skips the first 3-4 words. @JakeSeo did you find the solution? |
Which API doesn't behave as documented, and how does it misbehave?
I tried to create my own StreamAudioSource, and injected it as the audio source for my streaming audio.
It works but it seems that last few chunks of the stream is not being played. I tried to check the library code and the part where local audio server is created and listens to incoming requests, the corresponding proxy handler for the audio streaming is triggered two times, when the stream starts and ends.
I don't understand why the handler is triggered when the stream ends. When the handler is triggered, the stream is already finished, so it closes the listeners right away. At this point, audio is not finished so the player cuts the audio before the last few chunks are played. Is this suppose to happen? or am I missing something?
here's the code that I think causes the problem:
you can see my full code below:
Minimal reproduction project
https://github.com/JakeSeo/just_audio
To Reproduce (i.e. user steps, not code)
Steps to reproduce the behavior:
run the example code of just_audio inside the repository above.
Error messages
Expected behavior
The audio is played until the end without being cut down.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Flutter SDK version
Additional context
The text was updated successfully, but these errors were encountered: