GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Speech: encoding for speech to text ? · Issue #4360 · googleapis/google-cloud-python

Speech: encoding for speech to text ? #4360

New issue
Copy link
New issue
Copy link
Closed
Closed
Speech: encoding for speech to text ?#4360
Copy link
Assignees
amgsharma
Labels
api: speechIssues related to the Speech-to-Text API.

Description

@amgsharma
amgsharma
opened on Nov 8, 2017
Issue body actions

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.

Reacted by Dariush Azimi

Activity

  1. chemelnucfin
    changed the title [-]encoding for speech to text ?[/-] [+]Speech: encoding for speech to text ?[/+] on Nov 8, 2017
  2. chemelnucfin
    added
    api: speechIssues related to the Speech-to-Text API.
    on Nov 8, 2017
  3. amgsharma commented on Nov 8, 2017

    @amgsharma
    amgsharma
    on Nov 8, 2017
    Author
    More actions

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

    Reacted by Dariush Azimi
  4. amgsharma
    closed this as completedon Nov 8, 2017
  5. dariushazimi commented on Apr 18, 2018

    @dariushazimi
    dariushazimi
    on Apr 18, 2018
    More actions

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

  6. tseaver commented on Apr 18, 2018

    @tseaver
    tseaver
    on Apr 18, 2018
    Contributor
    More actions

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

  7. JustinBeckwith
    assigned
    amgsharma
    on Feb 1, 2021
  8. parthea
    added 3 commits that reference this issue on Oct 21, 2023

    fix(translate): fix a broken test [(#4360)](GoogleCloudPlatform/pytho…

    655bc03

    fix(translate): fix a broken test [(#4360)](GoogleCloudPlatform/pytho…

    b124685

    chore: release 2.0.0 (#68)

    629a2a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @amgsharma
    amgsharma

Labels

api: speechIssues related to the Speech-to-Text API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.