Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
import numpy as np
|
| 4 |
-
from google.cloud import speech_v1
|
|
|
|
| 5 |
from google.protobuf import timestamp_pb2
|
| 6 |
|
| 7 |
import os
|
|
@@ -29,17 +30,26 @@ def transcribe(audio_bytes):
|
|
| 29 |
"""Transcribe audio bytes to text using Google Cloud Speech to Text."""
|
| 30 |
|
| 31 |
# Crea un cliente de Speech to Text
|
| 32 |
-
client = speech_v1.SpeechClient()
|
|
|
|
| 33 |
|
| 34 |
# Configura la configuración de la solicitud
|
| 35 |
-
config = speech_v1.RecognitionConfig()
|
| 36 |
-
config.language_code = "es-AR"
|
| 37 |
-
config.encoding = speech_v1.RecognitionConfig.Encoding.LINEAR16
|
| 38 |
-
config.sample_rate_hertz = 16000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# Crea una solicitud de reconocimiento de audio
|
| 41 |
-
audio = speech_v1.RecognitionAudio(content=audio_bytes)
|
| 42 |
-
request = speech_v1.RecognizeSpeechRequest(config=config, audio=audio)
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# Realiza la transcripción
|
| 45 |
response = client.recognize_speech(request)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
import numpy as np
|
| 4 |
+
#from google.cloud import speech_v1
|
| 5 |
+
from google.cloud import speech
|
| 6 |
from google.protobuf import timestamp_pb2
|
| 7 |
|
| 8 |
import os
|
|
|
|
| 30 |
"""Transcribe audio bytes to text using Google Cloud Speech to Text."""
|
| 31 |
|
| 32 |
# Crea un cliente de Speech to Text
|
| 33 |
+
#client = speech_v1.SpeechClient()
|
| 34 |
+
client = speech.SpeechClient()
|
| 35 |
|
| 36 |
# Configura la configuración de la solicitud
|
| 37 |
+
#config = speech_v1.RecognitionConfig()
|
| 38 |
+
#config.language_code = "es-AR"
|
| 39 |
+
#config.encoding = speech_v1.RecognitionConfig.Encoding.LINEAR16
|
| 40 |
+
#config.sample_rate_hertz = 16000
|
| 41 |
+
config = speech.RecognitionConfig(
|
| 42 |
+
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
|
| 43 |
+
enable_automatic_punctuation=True,
|
| 44 |
+
audio_channel_count=2,
|
| 45 |
+
language_code="es-AR",
|
| 46 |
+
)
|
| 47 |
|
| 48 |
# Crea una solicitud de reconocimiento de audio
|
| 49 |
+
#audio = speech_v1.RecognitionAudio(content=audio_bytes)
|
| 50 |
+
#request = speech_v1.RecognizeSpeechRequest(config=config, audio=audio)
|
| 51 |
+
audio = speech.RecognitionAudio(content=audio_bytes)
|
| 52 |
+
request = speech.RecognizeSpeechRequest(config=config, audio=audio)
|
| 53 |
|
| 54 |
# Realiza la transcripción
|
| 55 |
response = client.recognize_speech(request)
|