Error handling for missing FFmpeg in start_ffmpeg_decoder
Browse files
whisperlivekit/audio_processor.py
CHANGED
|
@@ -83,10 +83,33 @@ class AudioProcessor:
|
|
| 83 |
|
| 84 |
def start_ffmpeg_decoder(self):
|
| 85 |
"""Start FFmpeg process for WebM to PCM conversion."""
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
async def restart_ffmpeg(self):
|
| 92 |
"""Restart the FFmpeg process after failure."""
|
|
|
|
| 83 |
|
| 84 |
def start_ffmpeg_decoder(self):
|
| 85 |
"""Start FFmpeg process for WebM to PCM conversion."""
|
| 86 |
+
try:
|
| 87 |
+
return (ffmpeg.input("pipe:0", format="webm")
|
| 88 |
+
.output("pipe:1", format="s16le", acodec="pcm_s16le",
|
| 89 |
+
ac=self.channels, ar=str(self.sample_rate))
|
| 90 |
+
.run_async(pipe_stdin=True, pipe_stdout=True, pipe_stderr=True))
|
| 91 |
+
except FileNotFoundError:
|
| 92 |
+
error = """
|
| 93 |
+
FFmpeg is not installed or not found in your system's PATH.
|
| 94 |
+
Please install FFmpeg to enable audio processing.
|
| 95 |
+
|
| 96 |
+
Installation instructions:
|
| 97 |
+
|
| 98 |
+
# Ubuntu/Debian:
|
| 99 |
+
sudo apt update && sudo apt install ffmpeg
|
| 100 |
+
|
| 101 |
+
# macOS (using Homebrew):
|
| 102 |
+
brew install ffmpeg
|
| 103 |
+
|
| 104 |
+
# Windows:
|
| 105 |
+
# 1. Download the latest static build from https://ffmpeg.org/download.html
|
| 106 |
+
# 2. Extract the archive (e.g., to C:\\FFmpeg).
|
| 107 |
+
# 3. Add the 'bin' directory (e.g., C:\\FFmpeg\\bin) to your system's PATH environment variable.
|
| 108 |
+
|
| 109 |
+
After installation, please restart the application.
|
| 110 |
+
"""
|
| 111 |
+
logger.error(error)
|
| 112 |
+
raise FileNotFoundError(error)
|
| 113 |
|
| 114 |
async def restart_ffmpeg(self):
|
| 115 |
"""Restart the FFmpeg process after failure."""
|