Spaces:
Sleeping
Sleeping
Commit ·
603fb50
1
Parent(s): 9fd899f
feat: implement voice transcription service with FFmpeg audio processing and API routing
Browse files
backend/app/services/voice_service.py
CHANGED
|
@@ -14,11 +14,15 @@ class VoiceService:
|
|
| 14 |
import os
|
| 15 |
|
| 16 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# Explicitly convert webm to wav using ffmpeg since librosa sometimes fails on webm
|
| 18 |
wav_path = audio_path + ".wav"
|
| 19 |
try:
|
| 20 |
subprocess.run(
|
| 21 |
-
[
|
| 22 |
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
| 23 |
)
|
| 24 |
except subprocess.CalledProcessError as e:
|
|
|
|
| 14 |
import os
|
| 15 |
|
| 16 |
try:
|
| 17 |
+
# Get bundled ffmpeg executable path
|
| 18 |
+
import imageio_ffmpeg
|
| 19 |
+
ffmpeg_exe = imageio_ffmpeg.get_ffmpeg_exe()
|
| 20 |
+
|
| 21 |
# Explicitly convert webm to wav using ffmpeg since librosa sometimes fails on webm
|
| 22 |
wav_path = audio_path + ".wav"
|
| 23 |
try:
|
| 24 |
subprocess.run(
|
| 25 |
+
[ffmpeg_exe, "-y", "-i", audio_path, "-ar", "16000", "-ac", "1", wav_path],
|
| 26 |
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
| 27 |
)
|
| 28 |
except subprocess.CalledProcessError as e:
|
requirements.txt
CHANGED
|
@@ -42,4 +42,5 @@ safetensors>=0.5.0
|
|
| 42 |
soundfile==0.13.1
|
| 43 |
librosa==0.11.0
|
| 44 |
kokoro>=0.7.16
|
| 45 |
-
pydantic-settings
|
|
|
|
|
|
| 42 |
soundfile==0.13.1
|
| 43 |
librosa==0.11.0
|
| 44 |
kokoro>=0.7.16
|
| 45 |
+
pydantic-settings
|
| 46 |
+
imageio-ffmpeg
|