• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
yjyoon / whisper_server_speaches star
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB
  • Files
  • Commit
  • Branches
whisper_server_speachesfaster_whisper_servergradio_app.py
Download as .zip file
File name
Commit message
Commit date
.github/workflows
ci: add test action
2024-07-03
examples
docs: fix shell quote
2024-07-20
faster_whisper_server
chore: update default log level
2024-08-14
tests
feat: handle srt and vtt response formats
2024-07-20
.dockerignore
chore: ignore .env
2024-05-27
.envrc
init
2024-05-20
.gitattributes
docs: add live-transcription demo
2024-05-28
.gitignore
chore: update .gitignore
2024-07-03
.pre-commit-config.yaml
switch to basedpyright
2024-07-20
Dockerfile.cpu
fix task enum vals, fix env var parsing, improve gradio, use uv in dockerfile
2024-06-23
Dockerfile.cuda
fix task enum vals, fix env var parsing, improve gradio, use uv in dockerfile
2024-06-23
LICENSE
init
2024-05-20
README.md
Update README.md
2024-07-03
Taskfile.yaml
deps: update
2024-07-16
audio.wav
docs: update README.md
2024-05-27
compose.yaml
chore: update docker tag to latest
2024-06-03
flake.lock
init
2024-05-20
flake.nix
switch to basedpyright
2024-07-20
lsyncd.conf
chore: add lsyncd config
2024-06-03
overrides.txt
deps: update
2024-07-16
pyproject.toml
chore: update ruff target version
2024-08-14
requirements-all.txt
feat: handle srt and vtt response formats
2024-07-20
requirements-dev.txt
feat: handle srt and vtt response formats
2024-07-20
requirements.txt
feat: handle srt and vtt response formats
2024-07-20
File name
Commit message
Commit date
__init__.py
chore: rename to 'faster-whisper-server'
2024-05-27
asr.py
refactor
2024-07-20
audio.py
fix: Correct closing logic in AudioStream to prevent discarding remaining data
2024-07-17
config.py
chore: update default log level
2024-08-14
core.py
feat: handle srt and vtt response formats
2024-07-20
gradio_app.py
refactor
2024-07-20
logger.py
chore: fix ruff errors
2024-07-03
main.py
update cors pr
2024-08-10
server_models.py
refactor
2024-07-20
transcriber.py
refactor
2024-07-20
Fedir Zadniprovskyi 2024-07-20 a8efff4 refactor UNIX
Raw Open in browser Change history
from collections.abc import Generator import gradio as gr import httpx from httpx_sse import connect_sse from openai import OpenAI from faster_whisper_server.config import Config, Task TRANSCRIPTION_ENDPOINT = "/v1/audio/transcriptions" TRANSLATION_ENDPOINT = "/v1/audio/translations" TIMEOUT_SECONDS = 180 TIMEOUT = httpx.Timeout(timeout=TIMEOUT_SECONDS) def create_gradio_demo(config: Config) -> gr.Blocks: base_url = f"http://{config.host}:{config.port}" http_client = httpx.Client(base_url=base_url, timeout=TIMEOUT) openai_client = OpenAI(base_url=f"{base_url}/v1", api_key="cant-be-empty") def handler(file_path: str, model: str, task: Task, temperature: float, stream: bool) -> Generator[str, None, None]: if task == Task.TRANSCRIBE: endpoint = TRANSCRIPTION_ENDPOINT elif task == Task.TRANSLATE: endpoint = TRANSLATION_ENDPOINT if stream: previous_transcription = "" for transcription in streaming_audio_task(file_path, endpoint, temperature, model): previous_transcription += transcription yield previous_transcription else: yield audio_task(file_path, endpoint, temperature, model) def audio_task(file_path: str, endpoint: str, temperature: float, model: str) -> str: with open(file_path, "rb") as file: response = http_client.post( endpoint, files={"file": file}, data={ "model": model, "response_format": "text", "temperature": temperature, }, ) response.raise_for_status() return response.text def streaming_audio_task( file_path: str, endpoint: str, temperature: float, model: str ) -> Generator[str, None, None]: with open(file_path, "rb") as file: kwargs = { "files": {"file": file}, "data": { "response_format": "text", "temperature": temperature, "model": model, "stream": True, }, } with connect_sse(http_client, "POST", endpoint, **kwargs) as event_source: for event in event_source.iter_sse(): yield event.data def update_model_dropdown() -> gr.Dropdown: models = openai_client.models.list().data model_names: list[str] = [model.id for model in models] assert config.whisper.model in model_names recommended_models = {model for model in model_names if model.startswith("Systran")} other_models = [model for model in model_names if model not in recommended_models] model_names = list(recommended_models) + other_models return gr.Dropdown( # no idea why it's complaining choices=model_names, # pyright: ignore[reportArgumentType] label="Model", value=config.whisper.model, ) model_dropdown = gr.Dropdown( choices=[config.whisper.model], label="Model", value=config.whisper.model, ) task_dropdown = gr.Dropdown( choices=[task.value for task in Task], label="Task", value=Task.TRANSCRIBE, ) temperature_slider = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label="Temperature", value=0.0) stream_checkbox = gr.Checkbox(label="Stream", value=True) with gr.Interface( title="Whisper Playground", description="""Consider supporting the project by starring the <a href="https://github.com/fedirz/faster-whisper-server">repository on GitHub</a>.""", # noqa: E501 inputs=[ gr.Audio(type="filepath"), model_dropdown, task_dropdown, temperature_slider, stream_checkbox, ], fn=handler, outputs="text", ) as demo: demo.load(update_model_dropdown, inputs=None, outputs=model_dropdown) return demo

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up