Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import numpy as np
|
|
5 |
from google.cloud import speech
|
6 |
from google.protobuf import timestamp_pb2
|
7 |
|
|
|
8 |
import os
|
9 |
"""Lista los archivos en la carpeta de ejecución."""
|
10 |
archivos = os.listdir()
|
@@ -55,7 +56,18 @@ def transcribe_2(audio_bytes):
|
|
55 |
print(type(y))
|
56 |
y = y.astype(np.float32)
|
57 |
y /= np.max(np.abs(y))
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
# Sends the request to google to transcribe the audio
|
60 |
response = client.recognize(request={"config": config, "audio": audio})
|
61 |
transcript = []
|
|
|
5 |
from google.cloud import speech
|
6 |
from google.protobuf import timestamp_pb2
|
7 |
|
8 |
+
import io
|
9 |
import os
|
10 |
"""Lista los archivos en la carpeta de ejecución."""
|
11 |
archivos = os.listdir()
|
|
|
56 |
print(type(y))
|
57 |
y = y.astype(np.float32)
|
58 |
y /= np.max(np.abs(y))
|
59 |
+
|
60 |
+
import scipy.io.wavfile as wav
|
61 |
+
RATE = sr
|
62 |
+
numpydata = y
|
63 |
+
file_name = 'out.wav'
|
64 |
+
wav.write(file_name, RATE, numpydata)
|
65 |
+
#the path of your audio file
|
66 |
+
with io.open(file_name, "rb") as audio_file:
|
67 |
+
content = audio_file.read()
|
68 |
+
audio = speech.RecognitionAudio(content=content)
|
69 |
+
|
70 |
+
#audio = speech.RecognitionAudio(content=audio_bytes)
|
71 |
# Sends the request to google to transcribe the audio
|
72 |
response = client.recognize(request={"config": config, "audio": audio})
|
73 |
transcript = []
|