Spaces:
Running
Running
Download app/api/whisper.py from basyx/MediaRouter: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/basyx/MediaRouter/resolve/main/app/api/whisper.py
- Command line
-
hf download hf://spaces/basyx/MediaRouter/app/api/whisper.py
-
curl -L -o whisper.py https://huggingface.co/spaces/basyx/MediaRouter/resolve/main/app/api/whisper.py
1.14 kB
| from __future__ import annotations | |
| from fastapi import APIRouter, Request | |
| from app.api.media import get_processor | |
| from app.core.response import SuccessResponse | |
| router = APIRouter(prefix="/v1/whisper", tags=["whisper"]) | |
| async def _transcribe(request: Request, default_format: str | None = None) -> SuccessResponse: | |
| request.state.operation = "whisper.transcribe" | |
| processor = get_processor(request) | |
| resolved = await processor.resolver.resolve(request) | |
| if default_format and "output_format" not in resolved.params: | |
| resolved.params["output_format"] = default_format | |
| return await processor.run_whisper(resolved) | |
| async def transcribe(request: Request) -> SuccessResponse: | |
| return await _transcribe(request) | |
| async def subtitles(request: Request) -> SuccessResponse: | |
| return await _transcribe(request, "srt") | |
| async def detect_language(request: Request) -> SuccessResponse: | |
| return await _transcribe(request, "json") | |