voice icon indicating copy to clipboard operation
voice copied to clipboard

Camera + SpeechToText not working together

Open sebastien-abbal opened this issue 4 years ago • 7 comments

What is needed ? I want to record a video and transcode voice to text for subtitles for example.

What's the problem ? When I record a video, the react-native-camera component use the microphone. But when i start the @react-native-community/voice in the same time to record audio and transcode voice to text, the Voice component stops immediately (it's using microphone too). If i add a timeout to the Voice component, the video record stops immediately. There is a solution to start 2 components using microphone in the same time synchronously ?

What I do ?

/* ... IMPORTS ... */
import { RNCamera, FaceDetector } from 'react-native-camera';
import Voice from '@react-native-community/voice';

const CameraScreen = (props) => {
  
  /* ... CODE ... */
  
  useEffect(() => {
    function onSpeechStart() {
      console.log('Speech START');
    };
    function onSpeechEnd() {
      console.log('Speech END');
    };
    function onSpeechResults(e) {
      console.log(e.value);
    };
    function onSpeechError(e) {
      console.log(e);
    };
    Voice.onSpeechStart = onSpeechStart;
    Voice.onSpeechEnd = onSpeechEnd;
    Voice.onSpeechError = onSpeechError;
    Voice.onSpeechResults = onSpeechResults;
    return () => {
      Voice.destroy().then(Voice.removeAllListeners);
    };
  }, []);
  
  const cameraRecord = async () => {
    await Voice.start('fr-FR');
    camera.recordAsync({
      quality: RNCamera.Constants.VideoQuality["1080p"],
      orientation: "portrait"
    })
    .then(async (data) => {
      console.log(data);
    })
  }
  
  /* ... CODE ... */
  
  return (
    <View style={cameraStyle.container}>
    { /* ... RENDERING CODE ... */ }
    </View>
  )
}

export default CameraScreen;

Packages

  • react-native: "0.63.3"
  • react-native-camera: "git+https://[email protected]/react-native-community/react-native-camera.git"
  • @react-native-community/voice: "^1.1.9"

sebastien-abbal avatar Nov 24 '20 10:11 sebastien-abbal

Hi @saurus1993, I too face similar kind of problem. Did you get any solution?

sriram-23 avatar Feb 05 '21 11:02 sriram-23

Hi, i have same problem, did you get any solution? @saurus1993

AlkanV avatar Mar 02 '21 11:03 AlkanV

any update on this? @AlkanV @sriram-23 @sebastien-abbal

peyman-hakemi avatar Apr 19 '21 13:04 peyman-hakemi

Same problem but with react-native-audio-record, need to recognise and record audio at same time

Hirurgo avatar Apr 29 '21 22:04 Hirurgo

Any solution to this? I'm currently facing the same issue, I'm using @react-native-community/voice for speech-to-text but also have to save the recordings and the said package can't handle it so I tried using react-native-audio-recorder-player to record the audio but found out it's not possible to use them simultaneously

markcabadsan avatar May 18 '22 11:05 markcabadsan

Confirm. Not working with https://github.com/mrousavy/react-native-vision-camera

iOS - working, Android - "error": {"code": "7", "message": "7/No match"

rusakovic avatar Aug 15 '22 07:08 rusakovic

Anyone run into a solution?

adam-a avatar Jul 06 '23 22:07 adam-a