• 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: update how images are tagged, enable multi-arch builds
2024-06-03
examples
chore: update docker tag to latest
2024-06-03
faster_whisper_server
feat: add a playground
2024-06-23
pre-commit-scripts
misc: remove custom pre-commit ruff hooks
2024-06-23
tests
misc: tests
2024-06-23
.dockerignore
chore: ignore .env
2024-05-27
.envrc
init
2024-05-20
.gitattributes
docs: add live-transcription demo
2024-05-28
.gitignore
deps: add aider
2024-06-23
.pre-commit-config.yaml
misc: remove custom pre-commit ruff hooks
2024-06-23
Dockerfile.cpu
feat: allow using any ctraslate2 compatible model #14
2024-06-03
Dockerfile.cuda
feat: allow using any ctraslate2 compatible model #14
2024-06-03
LICENSE
init
2024-05-20
README.md
chore: update docker tag to latest
2024-06-03
Taskfile.yaml
ci: update how images are tagged, enable multi-arch builds
2024-06-03
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
deps: add httpx-sse dev
2024-06-03
lsyncd.conf
chore: add lsyncd config
2024-06-03
poetry.lock
move deps
2024-06-23
pyproject.toml
move deps
2024-06-23
File name
Commit message
Commit date
__init__.py
chore: rename to 'faster-whisper-server'
2024-05-27
asr.py
chore: rename to 'faster-whisper-server'
2024-05-27
audio.py
chore: rename to 'faster-whisper-server'
2024-05-27
config.py
feat: add a playground
2024-06-23
core.py
chore: rename to 'faster-whisper-server'
2024-05-27
gradio_app.py
feat: add a playground
2024-06-23
logger.py
chore: rename to 'faster-whisper-server'
2024-05-27
main.py
feat: add a playground
2024-06-23
server_models.py
chore: improve api docs
2024-06-14
transcriber.py
chore: rename to 'faster-whisper-server'
2024-05-27
utils.py
chore: rename to 'faster-whisper-server'
2024-05-27
Fedir Zadniprovskyi 2024-06-23 599a76d feat: add a playground UNIX
Raw Open in browser Change history
import os from typing import Generator import gradio as gr import httpx from httpx_sse import connect_sse from faster_whisper_server.config import Config, Task TRANSCRIPTION_ENDPOINT = "/v1/audio/transcriptions" TRANSLATION_ENDPOINT = "/v1/audio/translations" def create_gradio_demo(config: Config) -> gr.Blocks: host = os.getenv("UVICORN_HOST", "0.0.0.0") port = os.getenv("UVICORN_PORT", 8000) # NOTE: worth looking into generated clients http_client = httpx.Client(base_url=f"http://{host}:{port}", timeout=None) def handler( file_path: str | None, model: str, task: Task, temperature: float, stream: bool ) -> Generator[str, None, None]: if file_path is None: yield "" return if stream: yield from transcribe_audio_streaming(file_path, task, temperature, model) yield transcribe_audio(file_path, task, temperature, model) def transcribe_audio( file_path: str, task: Task, temperature: float, model: str ) -> str: if task == Task.TRANSCRIPTION: endpoint = TRANSCRIPTION_ENDPOINT elif task == Task.TRANSLATION: endpoint = TRANSLATION_ENDPOINT 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 transcribe_audio_streaming( file_path: str, task: Task, 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, }, } endpoint = ( TRANSCRIPTION_ENDPOINT if task == Task.TRANSCRIPTION else TRANSLATION_ENDPOINT ) with connect_sse(http_client, "POST", endpoint, **kwargs) as event_source: for event in event_source.iter_sse(): yield event.data model_dropdown = gr.Dropdown( # TODO: use output from /v1/models 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.TRANSCRIPTION, ) 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) demo = 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>.""", inputs=[ gr.Audio(type="filepath"), model_dropdown, task_dropdown, temperature_slider, stream_checkbox, ], fn=handler, outputs="text", ) 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