Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from google.cloud import speech_v1
- from google.cloud.speech_v1 import enums
- import json
- import os
- os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "Transcribe-2e49d9085e13.json"
- def sample_long_running_recognize():
- """
- Transcribe long audio file from Cloud Storage using asynchronous speech
- recognition
- Args:
- storage_uri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
- """
- client = speech_v1.SpeechClient()
- storage_uri = 'gs://transcribe420/komunikatorvreme.flac'
- # Sample rate in Hertz of the audio data sent
- sample_rate_hertz = 44100
- # The language of the supplied audio
- language_code = "sl"
- # Encoding of audio data sent. This sample sets this explicitly.
- # This field is optional for FLAC and WAV audio formats.
- encoding = enums.RecognitionConfig.AudioEncoding.FLAC
- config = {
- "sample_rate_hertz": sample_rate_hertz,
- "language_code": language_code,
- "encoding": encoding,
- }
- audio = {"uri": storage_uri}
- print(u"Waiting for operation to complete...")
- results = client.recognize(config, audio)
- print(results)
- #results = client.recognize(config,audio)
- #print(type(results))
- sample_long_running_recognize()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement