felixjunghans / google_speech

Flutter google spech
MIT License
69 stars 42 forks source link

LongRunningRecognize #29

Closed mdizman closed 1 year ago

mdizman commented 1 year ago

Hello, How can ı use longRunningRecognize function in Flutter ?


await speechToText.recognize(config, audio).then((value) {
      setState(() {
        text = value.results.map((e) => e.alternatives.first.transcript).join('\n');
      });
    }).whenComplete(() => setState(() {
          recognizeFinished = true;
          recognizing = false;
        }));

I want to convert audio recordings longer than 1 minute into text in my project. I used these codes when translating audio recordings shorter than 1 minute. But I couldn't use longRunningRecognize function. I would be happy if you help.

felixjunghans commented 1 year ago

Hi @mdizman maybe #6 will help you!?

mdizman commented 1 year ago

Thank you for your response.

 final responseLongRunning = await speechToText
        .longRunningRecognize(
            RecognitionConfigBeta(
              encoding: AudioEncoding.LINEAR16,
              model: RecognitionModel.basic,
              enableAutomaticPunctuation: true,
              sampleRateHertz: 16000,
              languageCode: 'en-US',
              useEnhanced: false,
            ),
            'gs://testFile/New Recording 6.m4a')

How can I assign a text variable? e.g:

.......audio).then((value) {
      setState(() {
        text = value.results.map((e) => e.alternatives.first.transcript).join('\n');
      });
felixjunghans commented 1 year ago

info in #44