Spaces:
Runtime error
Runtime error
increase accuracy
Browse files
__pycache__/transcription_service.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/transcription_service.cpython-311.pyc and b/__pycache__/transcription_service.cpython-311.pyc differ
|
|
|
transcription_service.py
CHANGED
|
@@ -1,10 +1,16 @@
|
|
| 1 |
import os
|
| 2 |
from google.cloud import speech
|
| 3 |
from openai import OpenAI
|
| 4 |
-
|
| 5 |
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'msq-ai-78bdccb055f4.json'
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def transcribe_speech_local(wav_file,language):
|
|
|
|
| 8 |
"""
|
| 9 |
Transcribes a local WAV file using Google's Speech-to-Text API.
|
| 10 |
"""
|
|
@@ -15,7 +21,8 @@ def transcribe_speech_local(wav_file,language):
|
|
| 15 |
|
| 16 |
audio = speech.RecognitionAudio(content=content)
|
| 17 |
config = speech.RecognitionConfig(
|
| 18 |
-
|
|
|
|
| 19 |
# Adjust this according to your file's sample rate
|
| 20 |
language_code=language,
|
| 21 |
enable_automatic_punctuation=True
|
|
|
|
| 1 |
import os
|
| 2 |
from google.cloud import speech
|
| 3 |
from openai import OpenAI
|
| 4 |
+
import subprocess
|
| 5 |
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'msq-ai-78bdccb055f4.json'
|
| 6 |
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
convert_wav_to_flac = lambda wav_file: subprocess.run(['ffmpeg', '-i', wav_file, '-y', '-ar', '16000', '-ac', '1', wav_file.replace('.wav', '.flac')], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 11 |
+
|
| 12 |
def transcribe_speech_local(wav_file,language):
|
| 13 |
+
|
| 14 |
"""
|
| 15 |
Transcribes a local WAV file using Google's Speech-to-Text API.
|
| 16 |
"""
|
|
|
|
| 21 |
|
| 22 |
audio = speech.RecognitionAudio(content=content)
|
| 23 |
config = speech.RecognitionConfig(
|
| 24 |
+
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
|
| 25 |
+
|
| 26 |
# Adjust this according to your file's sample rate
|
| 27 |
language_code=language,
|
| 28 |
enable_automatic_punctuation=True
|