Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to import in React.js | Not sure if browser support is available as no documentation about it #280

Closed
gajendra93 opened this issue Dec 21, 2016 · 5 comments
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@gajendra93
Copy link

Hi

I am referring this sample to use the Speech APIs in my React.js application

below is what i am trying to do


import Speech from '@google-cloud/speech';
import record from 'node-record-lpcm16';

const speech = Speech();
		const options = {
		    config: {
		      	// Configure these settings based on the audio you're transcribing
		      	encoding: 'LINEAR16',
		      	sampleRate: 16000
		    }
		};

		// Create a recognize stream
		const recognizeStream = speech.createRecognizeStream(options)
		    .on('error', console.error)
		    .on('data', (data) => process.stdout.write(data.results));

	  	// Start recording and send the microphone input to the Speech API
	  	record.start({ sampleRate: 16000 }).pipe(recognizeStream);

But this fails to instantiate the Speech object

Am i missing something or there is something which is not documented for use in React.js/Angular.js?

@jmdobry
Copy link
Member

jmdobry commented Dec 21, 2016

Is your application something that runs in the browser or on the server (via Node.js)? The samples in this repository only run on the server.

@rajiff
Copy link

rajiff commented Dec 21, 2016

@jmdobry it Brunson browser compiled using web pack on server for bundling

Can you suggest any alternative for using on browser or how we can change it, we can try change and create a pull request

@jmdobry
Copy link
Member

jmdobry commented Dec 22, 2016

You can manually make an HTTP request to the Google Cloud Speech API from the browser. You'll need an API Key to authenticate. With Angular 1.x, it might be something like:

$http({
  method: 'POST',
  url: 'https://speech.googleapis.com/v1beta1/speech:syncrecognize',
  params: {
    key: 'YOUR_API_KEY'
  },
  data: {
    config: {
      encoding: 'LINEAR16', // customize for your audio
      sampleRate: 16000 // customize for your audio
    },
    audio: {
      content: 'as0af8s7d0fa9sd7f=' // base64-encoded string of the content of your audio file
      // or if your audio file is in Google Cloud Storage, "uri" instead:
      // uri: 'gs://your-bucket/your-audio-file'
    }
  }
}).then(...);

I don't have a bigger example to give you at the moment, but when I do I'll post back here.

@rajiff
Copy link

rajiff commented Dec 23, 2016

Nice, only worry is, this will expose API key over browser, need to check

@jmdobry
Copy link
Member

jmdobry commented Aug 21, 2017

That is the concern. We generally expect there to be a proxy between the browser and the Speech API, such as your own backend server.

@jmdobry jmdobry closed this as completed Aug 21, 2017
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 6, 2020
ivanmkc pushed a commit that referenced this issue Nov 3, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
grayside pushed a commit that referenced this issue Nov 8, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
ahrarmonsur pushed a commit that referenced this issue Nov 16, 2022
ahrarmonsur pushed a commit that referenced this issue Nov 16, 2022
ace-n pushed a commit that referenced this issue Nov 16, 2022
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
ahrarmonsur pushed a commit that referenced this issue Nov 16, 2022
ahrarmonsur pushed a commit that referenced this issue Nov 16, 2022
ahrarmonsur pushed a commit that referenced this issue Nov 16, 2022
telpirion pushed a commit that referenced this issue Nov 16, 2022
* ProductSearch GA

* ProductSearch GA
ace-n pushed a commit that referenced this issue Nov 17, 2022
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
ace-n pushed a commit that referenced this issue Nov 17, 2022
ahrarmonsur pushed a commit that referenced this issue Nov 17, 2022
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]
ahrarmonsur pushed a commit that referenced this issue Nov 18, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
pattishin pushed a commit that referenced this issue Nov 18, 2022
🤖 I have created a release *beep* *boop*
---


## [1.19.0](googleapis/nodejs-ai-platform@v1.18.0...v1.19.0) (2022-03-24)


### Features

* add data_item_schema_uri, annotation_schema_uri, explanation_specs to ModelEvaluationExplanationSpec in aiplatform v1 model_evaluation.proto ([b769264](googleapis/nodejs-ai-platform@b769264))
* add ImportModelEvaluation in aiplatform v1 model_service.proto ([#280](googleapis/nodejs-ai-platform#280)) ([b769264](googleapis/nodejs-ai-platform@b769264))
* add ImportModelEvaluation in aiplatform v1beta1 model_service.proto ([b769264](googleapis/nodejs-ai-platform@b769264))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
NimJay pushed a commit that referenced this issue Nov 19, 2022
* Added create cluster sample for Cloud Dataproc

* Modify test and slight change to Dataproc success message

* Changed region tag to include 'dataproc'

* changed dataproc imports to explicit v1

* Added create cluster sample for Cloud Dataproc

Updated READMEs

ignore createCluster until it lands

Modify test and slight change to Dataproc success message

changed dataproc imports to explicit v1

* Adding updated Dataproc quickstart

* Added mocha commands imports to tests

Co-authored-by: Benjamin E. Coe <bencoe@google.com>
NimJay pushed a commit that referenced this issue Nov 19, 2022
* Added create cluster sample for Cloud Dataproc

* Modify test and slight change to Dataproc success message

* Changed region tag to include 'dataproc'

* changed dataproc imports to explicit v1

* Added create cluster sample for Cloud Dataproc

Updated READMEs

ignore createCluster until it lands

Modify test and slight change to Dataproc success message

changed dataproc imports to explicit v1

* Adding updated Dataproc quickstart

* Added mocha commands imports to tests

Co-authored-by: Benjamin E. Coe <bencoe@google.com>
pattishin pushed a commit that referenced this issue Nov 22, 2022
🤖 I have created a release *beep* *boop*
---


## [1.19.0](googleapis/nodejs-ai-platform@v1.18.0...v1.19.0) (2022-03-24)


### Features

* add data_item_schema_uri, annotation_schema_uri, explanation_specs to ModelEvaluationExplanationSpec in aiplatform v1 model_evaluation.proto ([b769264](googleapis/nodejs-ai-platform@b769264))
* add ImportModelEvaluation in aiplatform v1 model_service.proto ([#280](googleapis/nodejs-ai-platform#280)) ([b769264](googleapis/nodejs-ai-platform@b769264))
* add ImportModelEvaluation in aiplatform v1beta1 model_service.proto ([b769264](googleapis/nodejs-ai-platform@b769264))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants