Last active
October 6, 2018 16:38
-
-
Save kakittwo/2596ef2909084532cfcfe0a90556324e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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