Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Can I use this package in react-native mobile app ? #367

Closed
nileshprajapati007444 opened this issue May 27, 2019 · 5 comments
Closed

Can I use this package in react-native mobile app ? #367

nileshprajapati007444 opened this issue May 27, 2019 · 5 comments
Assignees
Labels
api: speech Issues related to the googleapis/nodejs-speech API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. web

Comments

@nileshprajapati007444
Copy link

I am creating voice chat app in react-native. I want to translate speech to text using google.

Can I use this package in react-native ? Is it supported ?

Please explain me in detail.

Thanks in advance.

@JustinBeckwith JustinBeckwith added needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. labels May 28, 2019
@JustinBeckwith
Copy link
Contributor

Greetings! What have you tried?

@nileshprajapati007444
Copy link
Author

nileshprajapati007444 commented May 29, 2019

@JustinBeckwith

I have tried with below steps:

(1) I have create new project in react-native with below command:
react-native init GoogleDemoApp

(2) Then install this package with below command:
npm install @google-cloud/speech --save

(3) import this package:

// In react-native latest version, below syntax to import package
import speech from '@google-cloud/speech';

// Above import syntax gives error, so i have tried to import as per this package documentation.
const speech = require('@google-cloud/speech');

(4) Run react-native app:
react-native run-android

Issue is that every time I am facing error, and not able to run sample app.

error: bundling failed: Error: Unable to resolve module path from /GoogleDemoApp/App.js: Module path does not exist in the Haste module map

Let me know if you still any question from myside to understand my issue.

@bcoe
Copy link
Contributor

bcoe commented Jun 5, 2019

@nileshprajapati007444 as it stands today, you cannot run nodejs-speech in react-native or other front-end application (although it's bundled for different mobile clients, I believe react-native ultimately executes JavaScript in what's essentially a browser environment).

One of the main issues, is that the http2 dependency that nodejs-speech relies on is not available in non-Node.js environments.

What I would recommend would be to run a thin web-server, using a technology like express, which executes nodejs-speech. Your react-native` application would then make an HTTP request using a module like node-fetch

@sgreenberg
Copy link

@nileshprajapati007444 and @callmehiphop - I'm closing out this issue since the feature request feels like it's well covered in googleapis/google-cloud-node#2933. Let me know if that seems wrong.

@sgreenberg sgreenberg self-assigned this Dec 13, 2019
@mbifulco
Copy link

mbifulco commented Jan 31, 2020

@bcoe - does your comment above hold true for create-react-app, as well?

full context: I'm trying to create an electron app that uses this api to process audio recorded locally. I've wrapped create-react-app in electron, but can't seem to get the nodejs-speech client to authenticate without crashing things.

code (located in a react component):

// read credentials from an environment variable
const keysEnvVar = process.env.REACT_APP_GOOGLE_CREDENTIALS;
// parse those credentials as JSON (have verified that this is working correctly)
const credentialKeys = JSON.parse(keysEnvVar);

// app crashes on this line
const client = new speech.SpeechClient({ credentials: credentialKeys });

The error trace shows the following (keys/IDs redacted):
Pasted_Image_1_30_20__8_40_PM

@google-cloud-label-sync google-cloud-label-sync bot added the api: speech Issues related to the googleapis/nodejs-speech API. label Jan 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: speech Issues related to the googleapis/nodejs-speech API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. web
Projects
None yet
Development

No branches or pull requests

5 participants