feat: Converted Speech to Text

parent 1ccd9569
#!/usr/bin/env python
# coding: utf-8
# In[1]:
# Imports the Google Cloud client library
from google.cloud import speech
# In[2]:
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="D:\Presently/key-file.json"
# In[3]:
# Instantiates a client
client = speech.SpeechClient()
# In[4]:
# The name of the audio file to transcribe
gcs_uri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw"
audio = speech.RecognitionAudio(uri=gcs_uri)
config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code="en-US",
)
# In[5]:
# Detects speech in the audio file
response = client.recognize(config=config, audio=audio)
for result in response.results:
print("Transcript: {}".format(result.alternatives[0].transcript))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment