From 33bb7441061779f0561ec25ab896df4da50912ae Mon Sep 17 00:00:00 2001 From: Fedir Zadniprovskyi Date: Thu, 13 Feb 2025 21:07:05 -0800 Subject: [PATCH] fix: 'typing.TypeAliasType' object is not iterable --- src/speaches/ui/tabs/stt.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/speaches/ui/tabs/stt.py b/src/speaches/ui/tabs/stt.py index 46ae8e3..6fe8272 100644 --- a/src/speaches/ui/tabs/stt.py +++ b/src/speaches/ui/tabs/stt.py @@ -1,6 +1,5 @@ from collections.abc import AsyncGenerator from pathlib import Path -from typing import Literal import gradio as gr import httpx @@ -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" @@ -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 = "" @@ -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", )