diff --git a/speech/cloud-client/transcribe_async.py b/speech/cloud-client/transcribe_async.py index 8457871b3d7..7008fe5fb0b 100644 --- a/speech/cloud-client/transcribe_async.py +++ b/speech/cloud-client/transcribe_async.py @@ -23,42 +23,9 @@ """ import argparse -import io import time -def transcribe_file(speech_file): - """Transcribe the given audio file asynchronously.""" - from google.cloud import speech - speech_client = speech.Client() - - with io.open(speech_file, 'rb') as audio_file: - content = audio_file.read() - audio_sample = speech_client.sample( - content, - source_uri=None, - encoding='LINEAR16', - sample_rate_hertz=16000) - - operation = audio_sample.long_running_recognize('en-US') - - retry_count = 100 - while retry_count > 0 and not operation.complete: - retry_count -= 1 - time.sleep(2) - operation.poll() - - if not operation.complete: - print('Operation not complete and retry limit reached.') - return - - alternatives = operation.results - for alternative in alternatives: - print('Transcript: {}'.format(alternative.transcript)) - print('Confidence: {}'.format(alternative.confidence)) - # [END send_request] - - def transcribe_gcs(gcs_uri): """Asynchronously transcribes the audio file specified by the gcs_uri.""" from google.cloud import speech @@ -98,5 +65,3 @@ def transcribe_gcs(gcs_uri): args = parser.parse_args() if args.path.startswith('gs://'): transcribe_gcs(args.path) - else: - transcribe_file(args.path) diff --git a/speech/cloud-client/transcribe_async_test.py b/speech/cloud-client/transcribe_async_test.py index 8d719753d12..f14d8afe003 100644 --- a/speech/cloud-client/transcribe_async_test.py +++ b/speech/cloud-client/transcribe_async_test.py @@ -19,14 +19,6 @@ RESOURCES = os.path.join(os.path.dirname(__file__), 'resources') -def test_transcribe(capsys): - transcribe_async.transcribe_file( - os.path.join(RESOURCES, 'audio.raw')) - out, err = capsys.readouterr() - - assert re.search(r'how old is the Brooklyn Bridge', out, re.DOTALL | re.I) - - def test_transcribe_gcs(capsys): transcribe_async.transcribe_gcs( 'gs://python-docs-samples-tests/speech/audio.raw')