Skip to content

Instantly share code, notes, and snippets.

@kakittwo
Last active October 6, 2018 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kakittwo/2596ef2909084532cfcfe0a90556324e to your computer and use it in GitHub Desktop.
Save kakittwo/2596ef2909084532cfcfe0a90556324e to your computer and use it in GitHub Desktop.
def formWordList():
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
import argparse
import io
speech_file = "/home/kakitone/Desktop/googlemap/final.wav"
client = speech.SpeechClient()
with io.open(speech_file, 'rb') as audio_file:
content = audio_file.read()
audio = types.RecognitionAudio(content=content)
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=37500,
language_code='en-US')
operation = client.long_running_recognize(config, audio)
print('Waiting for Google Cloud Speech-to-Text to complete...')
response = operation.result(timeout=90)
combinedStr = ""
for result in response.results:
combinedStr += result.alternatives[0].transcript + " "
combinedStr = unicodedata.normalize('NFKD', combinedStr).encode('ascii','ignore')
return combinedStr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment