Use of ogg format
This commit is contained in:
parent
f4e7b55e97
commit
b94be5a668
8
main.py
8
main.py
|
@ -35,7 +35,7 @@ def calculate_api_g(response: Response):
|
|||
|
||||
import os
|
||||
|
||||
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "/home/mario/.config/gcloud/application_default_credentials.json"
|
||||
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "token.json"
|
||||
|
||||
def transcribe_ogg_audio(audio_file_path, language_code='es-US'):
|
||||
client = speech_v1.SpeechClient()
|
||||
|
@ -45,12 +45,12 @@ def transcribe_ogg_audio(audio_file_path, language_code='es-US'):
|
|||
|
||||
audio = speech_v1.RecognitionAudio(content=content)
|
||||
config = speech_v1.RecognitionConfig(
|
||||
encoding=types.RecognitionConfig.AudioEncoding.FLAC, # Use OGG encoding
|
||||
sample_rate_hertz=44100, # Update this to match your audio file
|
||||
encoding=types.RecognitionConfig.AudioEncoding.OGG_OPUS,#.FLAC, # Use OGG encoding
|
||||
sample_rate_hertz=48000, # Update this to match your audio file
|
||||
language_code=language_code,
|
||||
)
|
||||
|
||||
response = client.recognize(config=config, audio=audio)
|
||||
|
||||
return list(response.results[0].alternatives)[0].transcript
|
||||
#results.alternatives[0].transcript
|
||||
#results.alternatives[0].transcript
|
||||
|
|
Loading…
Reference in New Issue