Skip to content

Feat: FastRTC version of Whisper CPP speech to text to Docs#324

Merged
freddyaboulton merged 1 commit intogradio-app:mainfrom
mahimairaja:docs/fastrtc-whisper-cpp
May 30, 2025
Merged

Feat: FastRTC version of Whisper CPP speech to text to Docs#324
freddyaboulton merged 1 commit intogradio-app:mainfrom
mahimairaja:docs/fastrtc-whisper-cpp

Conversation

@mahimairaja
Copy link
Contributor

What does this PR does?

  • Add documentation for FastRTC Whisper CPP

Relevant Links

PyPI: https://pypi.org/project/fastrtc-whisper-cpp/

Repo: https://github.com/mahimairaja/fastrtc-whisper-cpp

Issue - here

Installation

$ pip install "fastrtc-whisper-cpp[audio]" 

# load_audio internally uses librosa - optional dependency

Demo script:

from fastrtc_whisper_cpp import get_stt_model, load_audio

model = get_stt_model(model="base.en")

audio_data = load_audio("test.wav")

text = model.stt(audio_data)

print(f'Transcription: {text}')

With FastRTC

from fastrtc import (ReplyOnPause, Stream, get_tts_model)
from fastrtc_whisper_cpp import get_stt_model
from openai import OpenAI


client = OpenAI()

stt_model = get_stt_model()
tts_model = get_tts_model()

def echo(audio):
    prompt = stt_model.stt(audio)
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": prompt}],
        max_tokens=200,
    )
    prompt = response.choices[0].message.content
    for audio_chunk in tts_model.stream_tts_sync(prompt):
        yield audio_chunk

stream = Stream(ReplyOnPause(echo), modality="audio", mode="send-receive")

stream.ui.launch()

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great @mahimairaja !

@freddyaboulton
Copy link
Collaborator

Thank you!

@freddyaboulton freddyaboulton merged commit 1179f8e into gradio-app:main May 30, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants