1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Speech recognition x audio recording simultaneously -flutter-

Discussão em 'Mobile' iniciado por Stack, Outubro 12, 2024 às 23:23.

  1. Stack

    Stack Membro Participativo

    Is it possible to recognize speech using speech_to_text while also recording the audio using flutter sound recorder? simultaneously. I'm stuck I've been troubleshooting all day and now I'm thinking maybe it's due to conflict in mic access ..? So if it's any suggestions? I need to do both task simultaneously and would really rather to have the text recognized in real time rather than transcripting later.

    void _startListening() async { // This function now relies on _startRecording _startRecording(); // Starts both recording and listening }

    `v

    oid _startRecording() async {
    if (!_isRecording && !_speechToText.isListening) { // Only start if not already recording or listening
    Directory directory = await getApplicationDocumentsDirectory();
    _audioPath = '${directory.path}/${DateTime.now().millisecondsSinceEpoch}.aac';
    try {
    await _recorder.startRecorder(toFile: _audioPath);
    _speechToText.listen(onResult: _onSpeechResult);
    setState(() {
    _isRecording = true;
    isListening = true;
    print('Recorder started, file at: $_audioPath');
    _animationController.repeat();
    });
    } catch (e) {
    print('Failed to start recorder and speech recognition: $e');
    }
    }
    else {
    print('-- already recording..? -- ');
    }
    }`


    I tried every ordering of these tasks stopping/starting recogntion/recording and no matter what only one would work either reco or rerc but not both. So is it even possible? how? or should I stop trying?

    Continue reading...

Compartilhe esta Página