
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
react-native-google-cloud-speech-to-text
Advanced tools
Google cloud speech to text streaming GRPC module
Google cloud speech to text streaming GRPC module
By default, module read google cloud api key from google services json file. So android may need to Set Up Google Play Services. and make sure your api key can access to Cloud services. API key can also replace by
setApiKey()
method in js code.
yarn add react-native-google-cloud-speech-to-text
import * as React from 'react';
import {
StyleSheet,
View,
Text,
Button,
SafeAreaView,
PermissionsAndroid,
} from 'react-native';
import GoogleCloudSpeechToText, {
SpeechRecognizeEvent,
VoiceStartEvent,
SpeechErrorEvent,
VoiceEvent,
SpeechStartEvent,
} from 'react-native-google-cloud-speech-to-text';
import { useEffect } from 'react';
const Separator = () => <View style={styles.separator} />;
export default function App() {
const [transcript, setResult] = React.useState<string>('');
useEffect(() => {
PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO, {
title: 'Cool Photo App Camera Permission',
message:
'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
});
}, []);
useEffect(() => {
// GoogleCloudSpeechToText.setApiKey('key_____');
GoogleCloudSpeechToText.onVoice(onVoice);
GoogleCloudSpeechToText.onVoiceStart(onVoiceStart);
GoogleCloudSpeechToText.onVoiceEnd(onVoiceEnd);
GoogleCloudSpeechToText.onSpeechError(onSpeechError);
GoogleCloudSpeechToText.onSpeechRecognized(onSpeechRecognized);
GoogleCloudSpeechToText.onSpeechRecognizing(onSpeechRecognizing);
return () => {
GoogleCloudSpeechToText.removeListeners();
};
}, []);
const onSpeechError = (_error: SpeechErrorEvent) => {
console.log('onSpeechError: ', _error);
};
const onSpeechRecognized = (result: SpeechRecognizeEvent) => {
console.log('onSpeechRecognized: ', result);
setResult(result.transcript);
};
const onSpeechRecognizing = (result: SpeechRecognizeEvent) => {
console.log('onSpeechRecognizing: ', result);
setResult(result.transcript);
};
const onVoiceStart = (_event: VoiceStartEvent) => {
console.log('onVoiceStart', _event);
};
const onVoice = (_event: VoiceEvent) => {
console.log('onVoice', _event);
};
const onVoiceEnd = () => {
console.log('onVoiceEnd: ');
};
const startRecognizing = async () => {
const result: SpeechStartEvent = await GoogleCloudSpeechToText.start({
speechToFile: true,
});
console.log('startRecognizing', result);
};
const stopRecognizing = async () => {
await GoogleCloudSpeechToText.stop();
};
return (
<SafeAreaView style={styles.container}>
<View>
<Text style={styles.title}>{transcript}</Text>
<Button title="Start me" onPress={startRecognizing} />
</View>
<Separator />
<View>
<Text style={styles.title}>
Adjust the color in a way that looks standard on each platform. On
iOS, the color prop controls the color of the text. On Android, the
color adjusts the background color of the button.
</Text>
<Button title="Stop me" color="#f194ff" onPress={stopRecognizing} />
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
marginHorizontal: 16,
},
title: {
textAlign: 'center',
marginVertical: 8,
},
fixToText: {
flexDirection: 'row',
justifyContent: 'space-between',
},
separator: {
marginVertical: 8,
borderBottomColor: '#737373',
borderBottomWidth: StyleSheet.hairlineWidth,
},
});
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
FAQs
Google cloud speech to text streaming GRPC module
The npm package react-native-google-cloud-speech-to-text receives a total of 2 weekly downloads. As such, react-native-google-cloud-speech-to-text popularity was classified as not popular.
We found that react-native-google-cloud-speech-to-text demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.