Skip to content

How do I play directly stream the speech to audio out? #52

Answered by thijse
thijse asked this question in Q&A
Discussion options

You must be logged in to vote

Solved it! This works:

        public async Task TextToOut(string text)
        {
            _voice = (await _api.VoicesEndpoint.GetAllVoicesAsync()).FirstOrDefault();

            // Setup BufferedWaveProvider with the correct format
            var waveFormat = new WaveFormat(24000, 16, 1); // Assuming mono channel; adjust if necessary
            var bufferedWaveProvider = new BufferedWaveProvider(waveFormat)
            {
                BufferDuration = TimeSpan.FromSeconds(10), // Set a buffer duration to avoid overflow
                DiscardOnBufferOverflow = true // Discard excess data if the buffer is full
            };

            var waveOut = new WaveOutEvent();
            

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by StephenHodgson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant