Add first-class support for Cartesia text-to-speech (#298)

* Demo

* patient intake

* cartesia

* Add cartesia

* Fix

* lint

* Move test

* Fix

* Fix

* Fix

* Fix
This commit is contained in:
Freddy Boulton
2025-04-23 15:15:57 -04:00
committed by GitHub
parent 24349dee0c
commit 745701c79c
4 changed files with 99 additions and 14 deletions

11
test/test_tts.py Normal file
View File

@@ -0,0 +1,11 @@
import pytest
from fastrtc.text_to_speech.tts import get_tts_model
@pytest.mark.parametrize("model", ["kokoro"])
def test_tts_long_prompt(model):
model = get_tts_model(model=model)
prompt = "It may be that this communication will be considered as a madman's freak but at any rate it must be admitted that in its clearness and frankness it left nothing to be desired The serious part of it was that the Federal Government had undertaken to treat a sale by auction as a valid concession of these undiscovered territories Opinions on the matter were many Some readers saw in it only one of those prodigious outbursts of American humbug which would exceed the limits of puffism if the depths of human credulity were not unfathomable"
for i, chunk in enumerate(model.stream_tts_sync(prompt)):
print(f"Chunk {i}: {chunk[1].shape}")

View File

@@ -39,6 +39,7 @@ class MinimalTestStream(WebRTCConnectionMixin):
)
self.time_limit = time_limit
self.allow_extra_tracks = allow_extra_tracks
self.server_rtc_configuration = None
def mount(self, app: FastAPI, path: str = ""):
from fastapi import APIRouter