{"id":49072,"library":"react-native-google-cloud-speech-to-text","title":"React Native Google Cloud Speech-to-Text","description":"A React Native module for streaming speech recognition using the Google Cloud Speech-to-Text API via gRPC. Version 0.5.4 supports Android only (iOS coming soon) and requires React Native >= 0.60. Configured to read API key from google-services.json by default, but allows runtime override via `setApiKey()`. Differentiator: provides low-level streaming events (voice start, voice end, speech recognized, speech recognizing) for fine-grained control, unlike higher-level wrappers. The library ships TypeScript definitions and exposes event types. Release cadence is irregular; the module is experimental with limited iOS support.","status":"active","version":"0.5.4","language":"javascript","source_language":"en","source_url":"https://github.com/huynqbibabo/react-native-google-cloud-speech-to-text","tags":["javascript","react-native","ios","android","typescript"],"install":[{"cmd":"npm install react-native-google-cloud-speech-to-text","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-google-cloud-speech-to-text","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-google-cloud-speech-to-text","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for React components and hooks.","package":"react","optional":false},{"reason":"Peer dependency for React Native platform APIs and native module integration.","package":"react-native","optional":false}],"imports":[{"note":"Default export is the main module object. Named import will fail.","wrong":"import { GoogleCloudSpeechToText } from 'react-native-google-cloud-speech-to-text'","symbol":"GoogleCloudSpeechToText","correct":"import GoogleCloudSpeechToText from 'react-native-google-cloud-speech-to-text'"},{"note":"TypeScript types are exported as named exports. In CJS, require() may not work for types; use ESM import style.","wrong":"const { SpeechRecognizeEvent } = require('react-native-google-cloud-speech-to-text')","symbol":"SpeechRecognizeEvent","correct":"import GoogleCloudSpeechToText, { SpeechRecognizeEvent } from 'react-native-google-cloud-speech-to-text'"},{"note":"TypeScript event types are exported separately, not attached to the default export.","wrong":"import GoogleCloudSpeechToText from 'react-native-google-cloud-speech-to-text'; GoogleCloudSpeechToText.VoiceStartEvent","symbol":"VoiceStartEvent","correct":"import { VoiceStartEvent } from 'react-native-google-cloud-speech-to-text'"},{"note":"With CJS, the default export is under .default. Omitting .default will give an empty object.","wrong":"const GCSpeech = require('react-native-google-cloud-speech-to-text')","symbol":"require('react-native-google-cloud-speech-to-text')","correct":"const GCSpeech = require('react-native-google-cloud-speech-to-text').default;"}],"quickstart":{"code":"import React, { useEffect } from 'react';\nimport { View, Button, PermissionsAndroid } from 'react-native';\nimport GoogleCloudSpeechToText, {\n  SpeechRecognizeEvent,\n  VoiceStartEvent,\n  SpeechErrorEvent,\n  VoiceEvent,\n  SpeechStartEvent,\n} from 'react-native-google-cloud-speech-to-text';\n\n// Request audio permission (Android)\nPermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO, {\n  title: 'Microphone Permission',\n  message: 'App needs access to microphone for speech recognition.',\n  buttonPositive: 'Grant',\n});\n\n// Optionally set API key\nGoogleCloudSpeechToText.setApiKey(process.env.GOOGLE_API_KEY ?? '');\n\n// Set up event listeners\nconst onSpeechRecognized = (result: SpeechRecognizeEvent) => {\n  console.log('Transcript:', result.transcript);\n};\nGoogleCloudSpeechToText.onSpeechRecognized(onSpeechRecognized);\n\n// Start recognition\nconst start = async () => {\n  const result: SpeechStartEvent = await GoogleCloudSpeechToText.start({\n    speechToFile: false,\n    locale: 'en-US',\n  });\n  console.log('Started', result);\n};\n\n// Stop recognition\nconst stop = async () => {\n  await GoogleCloudSpeechToText.stop();\n  GoogleCloudSpeechToText.removeListeners();\n};\n\nexport default function App() {\n  return (\n    <View>\n      <Button title=\"Start\" onPress={start} />\n      <Button title=\"Stop\" onPress={stop} />\n    </View>\n  );\n}","lang":"typescript","description":"Sets up and runs streaming speech recognition with event listeners, API key, and permission handling."},"warnings":[{"fix":"Use on Android or wait for iOS update. React Native module may crash on iOS.","message":"iOS not yet supported — module currently Android-only.","severity":"breaking","affected_versions":"all"},{"fix":"Either configure google-services.json or call GoogleCloudSpeechToText.setApiKey('your-key') early.","message":"Default API key is read from google-services.json (Android). setApiKey() overrides it — must be called before start().","severity":"gotcha","affected_versions":"all"},{"fix":"Call GoogleCloudSpeechToText.removeListeners() in useEffect cleanup or componentWillUnmount.","message":"Event listeners (onVoice, onVoiceStart, etc.) do not return cleanup functions; must manually call removeListeners() during unmount.","severity":"gotcha","affected_versions":"all"},{"fix":"Set speechToFile: false for now; monitor updates for file recording feature.","message":"The 'speechToFile' option may be removed or behavior may change; currently marked as 'coming soon'.","severity":"deprecated","affected_versions":"~0.5.4"},{"fix":"Follow Google Cloud quickstart to enable the API and create a key with correct restrictions.","message":"Google Cloud speech API requires billing enabled and API key whitelisted for Speech-to-Text.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.5.4':29 '0.60':40 'allow':51 'android':31,107 'api':25,44 'cadenc':91 'cloud':4,20 'come':34 'configur':41 'control':75 'default':49 'definit':85 'differenti':56 'end':66 'event':62,88 'experiment':97 'expos':87 'fine':73 'fine-grain':72 'googl':3,19 'google-services.json':47 'grain':74 'grpc':27 'higher':78 'higher-level':77 'io':33,100,106 'irregular':93 'javascript':102 'key':45 'level':60,79 'librari':82 'limit':99 'low':59 'low-level':58 'modul':12,95 'nativ':2,11,39,105 'overrid':53 'provid':57 'react':1,10,38,104 'react-nat':103 'read':43 'recogn':68,70 'recognit':16 'releas':90 'requir':37 'runtim':52 'setapikey':55 'ship':83 'soon':35 'speech':6,15,22,67,69 'speech-to-text':5,21 'start':64 'stream':14,61 'support':30,101 'text':8,24 'type':89 'typescript':84,108 'unlik':76 'use':17 'version':28 'via':26,54 'voic':63,65 'wrapper':80","created_at":"2026-06-07T16:59:54.173545+00:00","updated_at":"2026-06-07T16:59:54.173545+00:00","problems":[{"fix":"Use GoogleCloudSpeechToText.start() not GoogleCloudSpeechToText()","cause":"Misunderstanding of the default import; trying to call it as a function instead of object method.","error":"GoogleCloudSpeechToText is not a function"},{"fix":"const GCSpeech = require('react-native-google-cloud-speech-to-text').default;","cause":"CJS require() did not access .default","error":"Cannot read property 'start' of undefined"},{"fix":"Ensure google-services.json is correctly placed (Android) or call setApiKey() with a valid key before start().","cause":"Missing or incorrect API key configuration.","error":"Speech error: API key not valid. Please pass a valid API key."},{"fix":"import { PermissionsAndroid } from 'react-native';","cause":"Trying to use PermissionsAndroid without importing from 'react-native'.","error":"PermissionsAndroid is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/huynqbibabo/react-native-google-cloud-speech-to-text#readme","github":"https://github.com/huynqbibabo/react-native-google-cloud-speech-to-text","docs":null,"changelog":null,"pypi":null,"npm":"react-native-google-cloud-speech-to-text","openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}