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

Speech: encoding for speech to text ? #4360

Closed
amgsharma opened this issue Nov 8, 2017 · 3 comments
Closed

Speech: encoding for speech to text ? #4360

amgsharma opened this issue Nov 8, 2017 · 3 comments
Assignees
Labels
api: speech Issues related to the Speech-to-Text API.

Comments

@amgsharma
Copy link

API: Speech
MAX OSX
Python v35

I'm trying to set up a basic example for speech to text.
I've used ffmpeg to extract audio from an mp4, then convert this audio from mp3 to flac.

My code is as follows (as per the example on the SPEECH API documentation)

import io
import os

Imports the Google Cloud client library

from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types

Instantiates a client

client = speech.SpeechClient()

The name of the audio file to transcribe

file_name = os.path.join(
os.path.dirname(file),
'data','mp4s', 'audio',
'0BuayZmFrINBZHBG7uHMAI4U6xx4MkRC.flac')

Loads the audio into memory

with io.open(file_name, 'rb') as audio_file:
content = audio_file.read()
audio = types.RecognitionAudio(content=content)

config = types.RecognitionConfig(
# encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
encoding='FLAC',
sample_rate_hertz=48000,
language_code='en-US')
import pdb;pdb.set_trace()

Detects speech in the audio file

response = client.recognize(config, audio)

for result in response.results:
print('Transcript: {}'.format(result.alternatives[0].transcript))

The current error I'm trying to debug is as follows:
google.gax.errors.RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Invalid audio channel count)>)

Haven't seen anything about this on the googles, so pardon if its a repeat.

@chemelnucfin chemelnucfin changed the title encoding for speech to text ? Speech: encoding for speech to text ? Nov 8, 2017
@chemelnucfin chemelnucfin added the api: speech Issues related to the Speech-to-Text API. label Nov 8, 2017
@amgsharma
Copy link
Author

Answer: Ensure 1 channel when converting as per this answer there:
https://stackoverflow.com/questions/39620198/google-cloud-speech-syncrecognize-invalid-argument

@dariushazimi
Copy link

dariushazimi commented Apr 18, 2018

@amgsharma Were you able to resolve the issue? Can you share the final version?

@tseaver
Copy link
Contributor

tseaver commented Apr 18, 2018

@dariushazimi You need to ensure that the audio file to be converted is mono, not stereo.

parthea pushed a commit that referenced this issue Oct 21, 2023
…n-docs-samples#4360)

* fix(translate): fix a broken test

fixes #4353

* use uuid

* fix builds
parthea pushed a commit that referenced this issue Oct 21, 2023
…n-docs-samples#4360)

* fix(translate): fix a broken test

fixes #4353

* use uuid

* fix builds
parthea pushed a commit that referenced this issue Oct 21, 2023
🤖 I have created a release \*beep\* \*boop\* 
---
## [2.0.0](https://www.github.com/googleapis/python-automl/compare/v1.0.1...v2.0.0) (2020-09-16)


### ⚠ BREAKING CHANGES

* move to microgen (#61)

### Features

* move to microgen ([#61](https://www.github.com/googleapis/python-automl/issues/61)) ([009085e](https://www.github.com/googleapis/python-automl/commit/009085e0a82d1d7729349746c2c8954d5d60e0a9))


### Bug Fixes

* **translate:** fix a broken test [([#4360](https://www.github.com/googleapis/python-automl/issues/4360))](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/4360) ([5f7d141](https://www.github.com/googleapis/python-automl/commit/5f7d141afe732acf7458a9ac98618e93baa93d38)), closes [#4353](https://www.github.com/googleapis/python-automl/issues/4353)
* `update_column_spec` typo in TablesClient docstring ([#18](https://www.github.com/googleapis/python-automl/issues/18)) ([9feb4cc](https://www.github.com/googleapis/python-automl/commit/9feb4cc5e04a01a4199da43400457cca6c0bfa05)), closes [#17](https://www.github.com/googleapis/python-automl/issues/17)
* update retry configs ([#44](https://www.github.com/googleapis/python-automl/issues/44)) ([7df9059](https://www.github.com/googleapis/python-automl/commit/7df905910b86721a6ee3a3b6c916a4f8e27d0aa7))


### Documentation

* add cancel operation sample ([abc5070](https://www.github.com/googleapis/python-automl/commit/abc507005d5255ed5adf2c4b8e0b23042a0bdf47))
* add samples from tables/automl ([#54](https://www.github.com/googleapis/python-automl/issues/54)) ([d225a5f](https://www.github.com/googleapis/python-automl/commit/d225a5f97c2823218b91a79e77d3383132875231)), closes [#2090](https://www.github.com/googleapis/python-automl/issues/2090) [#2100](https://www.github.com/googleapis/python-automl/issues/2100) [#2102](https://www.github.com/googleapis/python-automl/issues/2102) [#2103](https://www.github.com/googleapis/python-automl/issues/2103) [#2101](https://www.github.com/googleapis/python-automl/issues/2101) [#2110](https://www.github.com/googleapis/python-automl/issues/2110) [#2115](https://www.github.com/googleapis/python-automl/issues/2115) [#2150](https://www.github.com/googleapis/python-automl/issues/2150) [#2145](https://www.github.com/googleapis/python-automl/issues/2145) [#2203](https://www.github.com/googleapis/python-automl/issues/2203) [#2340](https://www.github.com/googleapis/python-automl/issues/2340) [#2337](https://www.github.com/googleapis/python-automl/issues/2337) [#2336](https://www.github.com/googleapis/python-automl/issues/2336) [#2339](https://www.github.com/googleapis/python-automl/issues/2339) [#2338](https://www.github.com/googleapis/python-automl/issues/2338) [#2276](https://www.github.com/googleapis/python-automl/issues/2276) [#2257](https://www.github.com/googleapis/python-automl/issues/2257) [#2424](https://www.github.com/googleapis/python-automl/issues/2424) [#2407](https://www.github.com/googleapis/python-automl/issues/2407) [#2501](https://www.github.com/googleapis/python-automl/issues/2501) [#2459](https://www.github.com/googleapis/python-automl/issues/2459) [#2601](https://www.github.com/googleapis/python-automl/issues/2601) [#2523](https://www.github.com/googleapis/python-automl/issues/2523) [#2005](https://www.github.com/googleapis/python-automl/issues/2005) [#3033](https://www.github.com/googleapis/python-automl/issues/3033) [#2806](https://www.github.com/googleapis/python-automl/issues/2806) [#3750](https://www.github.com/googleapis/python-automl/issues/3750) [#3571](https://www.github.com/googleapis/python-automl/issues/3571) [#3929](https://www.github.com/googleapis/python-automl/issues/3929) [#4022](https://www.github.com/googleapis/python-automl/issues/4022) [#4127](https://www.github.com/googleapis/python-automl/issues/4127)
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: speech Issues related to the Speech-to-Text API.
Projects
None yet
Development

No branches or pull requests

4 participants