Skip to content

Commit

Permalink
fix: 'typing.TypeAliasType' object is not iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedir Zadniprovskyi committed Feb 14, 2025
1 parent 5e76efe commit 33bb744
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/speaches/ui/tabs/stt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections.abc import AsyncGenerator
from pathlib import Path
from typing import Literal

import gradio as gr
import httpx
Expand All @@ -9,8 +8,6 @@
from speaches.config import Config
from speaches.ui.utils import http_client_from_gradio_req, openai_client_from_gradio_req

type Task = Literal["transcribe", "translate"]

TRANSCRIPTION_ENDPOINT = "/v1/audio/transcriptions"
TRANSLATION_ENDPOINT = "/v1/audio/translations"

Expand Down Expand Up @@ -60,13 +57,10 @@ async def streaming_audio_task(
yield event.data

async def whisper_handler(
file_path: str, model: str, task: Task, temperature: float, stream: bool, request: gr.Request
file_path: str, model: str, task: str, temperature: float, stream: bool, request: gr.Request
) -> AsyncGenerator[str, None]:
http_client = http_client_from_gradio_req(request, config)
if task == "transcribe":
endpoint = TRANSCRIPTION_ENDPOINT
elif task == "translate":
endpoint = TRANSLATION_ENDPOINT
endpoint = TRANSCRIPTION_ENDPOINT if task == "transcribe" else TRANSLATION_ENDPOINT

if stream:
previous_transcription = ""
Expand All @@ -84,7 +78,7 @@ async def whisper_handler(
value="Systran/faster-whisper-small",
)
task_dropdown = gr.Dropdown(
choices=[task.value for task in Task],
choices=["transcribe", "translate"],
label="Task",
value="transcribe",
)
Expand Down

0 comments on commit 33bb744

Please sign in to comment.