Skip to content

refactor: update translation script to support generic audio stream U…#24

Merged
PaulTR merged 1 commit into
mainfrom
chore/remove-yt
Jun 9, 2026
Merged

refactor: update translation script to support generic audio stream U…#24
PaulTR merged 1 commit into
mainfrom
chore/remove-yt

Conversation

@thorwebdev

Copy link
Copy Markdown
Collaborator

…RLs instead of YouTube-specific extraction

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the real-time translation CLI tool to stream and translate generic remote audio URLs instead of being restricted to YouTube videos. It removes the dependency on yt_dlp and updates the command-line arguments, making the --url parameter optional with a default sample audio file. Feedback suggests wrapping the ffmpeg subprocess execution in a try-except block to gracefully handle cases where ffmpeg is not installed on the user's system, preventing a cryptic crash.

return

print("[Info] Starting audio stream via ffmpeg...")
async def stream_audio_url(url: str, audio_queue: asyncio.Queue, original_playback_queue: asyncio.Queue = None, volume: float = 0.08):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If ffmpeg is not installed on the user's system, asyncio.create_subprocess_exec will raise a FileNotFoundError (or OSError), which will propagate and crash the application with a cryptic error message.

To improve the user experience, consider wrapping the subprocess creation in a try-except block and raising a more descriptive RuntimeError that guides the user to install ffmpeg.

For example:

try:
    process = await asyncio.create_subprocess_exec(
        'ffmpeg',
        '-i', url,
        '-f', 's16le',
        '-acodec', 'pcm_s16le',
        '-ar', str(SEND_SAMPLE_RATE),
        '-ac', str(CHANNELS),
        '-',
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.DEVNULL
    )
except OSError as e:
    raise RuntimeError(
        f"Failed to start ffmpeg ({e}). Please ensure ffmpeg is installed and available in your PATH."
    )

@PaulTR PaulTR merged commit d8f2fd2 into main Jun 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants