Hyejung
Hyejung

Reputation: 1272

Is there any way of providing Audio answer as stream with ChatGPT in Flutter?

I want to get answer from ChatGPT and provide answer as audio in Flutter.

When I look through document of ChatGPT API, I found text to speech.

https://platform.openai.com/docs/guides/text-to-speech

But this speaks input itself, not answer from question.

So Now what I do is I get answer from ChatGPT and then, after getting all answer, I read that answer strings from package flutter_tts (text to speech).

But the limit of this process is user should wait for answer to finished before AI speaks answer too long.

When I use ChatGPT 3.5 from app, It provides audio question and audio answer as stream. So audio answer comes so quickly after use asks.

And there's so many apps to provide ChatGPT answer with audio.

Is this function not provided in API Now? If so, How do they provide this function? please let me know.

Upvotes: 1

Views: 208

Answers (1)

Shiv Shrivas
Shiv Shrivas

Reputation: 63

you can try to convert that text answer into a voice I have done in android with TTS and in flutter with

 flutter_tts: ^3.2.0  # Check for the latest version on pub.dev

Try this method with any String

    Future<void> _speak(String text) async {
    await _flutterTts.setLanguage("en-US");  // Set language if needed
    await _flutterTts.setPitch(1.0);         // Set pitch if needed
    await _flutterTts.setSpeechRate(0.5);    // Set speech rate if needed
    await _flutterTts.speak(text);
  }

Upvotes: 0

Related Questions