Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added test.py
Empty file.
2 changes: 1 addition & 1 deletion tests/synthesizer/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def fixture_eleven_labs_synthesizer_env_api_key():

def create_play_ht_request_handler():
def request_handler(url, headers, **kwargs):
if headers["AUTHORIZATION"] != f"Bearer {MOCK_API_KEY}":
if headers["AUTHORIZATION"] != MOCK_API_KEY:
return CallbackResult(status=401)
if headers["X-USER-ID"] != MOCK_USER_ID:
return CallbackResult(status=401)
Expand Down
8 changes: 5 additions & 3 deletions vocode/streaming/models/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def stability_and_similarity_boost_check(cls, similarity_boost, values):
@validator("optimize_streaming_latency")
def optimize_streaming_latency_check(cls, optimize_streaming_latency):
if optimize_streaming_latency is not None and not (
0 <= optimize_streaming_latency <= 4
0 <= optimize_streaming_latency <= 4
):
raise ValueError("optimize_streaming_latency must be between 0 and 4.")
return optimize_streaming_latency
Expand Down Expand Up @@ -162,7 +162,8 @@ def override_voice_id_with_prompt(cls, voice_id, values):
return voice_id or COQUI_DEFAULT_SPEAKER_ID


PLAYHT_DEFAULT_VOICE_ID = "larry"
PLAYHT_DEFAULT_VOICE = "s3://peregrine-voices/mel28/manifest.json"
PLAYHT_DEFAULT_VOICE_ENGINE = "PlayHT2.0-turbo"


class PlayHtSynthesizerConfig(SynthesizerConfig, type=SynthesizerType.PLAY_HT.value):
Expand All @@ -171,7 +172,8 @@ class PlayHtSynthesizerConfig(SynthesizerConfig, type=SynthesizerType.PLAY_HT.va
speed: Optional[int] = None
seed: Optional[int] = None
temperature: Optional[int] = None
voice_id: str = PLAYHT_DEFAULT_VOICE_ID
voice: str = PLAYHT_DEFAULT_VOICE
voice_engine: str = PLAYHT_DEFAULT_VOICE_ENGINE
experimental_streaming: bool = False


Expand Down
7 changes: 4 additions & 3 deletions vocode/streaming/synthesizer/play_ht_synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from vocode.streaming.utils.mp3_helper import decode_mp3

TTS_ENDPOINT = "https://play.ht/api/v2/tts/stream"
TTS_ENDPOINT = "https://api.play.ht/api/v2/tts/stream"


class PlayHtSynthesizer(BaseSynthesizer[PlayHtSynthesizerConfig]):
Expand Down Expand Up @@ -46,16 +46,17 @@ async def create_speech(
bot_sentiment: Optional[BotSentiment] = None,
) -> SynthesisResult:
headers = {
"AUTHORIZATION": f"Bearer {self.api_key}",
"AUTHORIZATION": self.api_key,
"X-USER-ID": self.user_id,
"Accept": "audio/mpeg",
"Content-Type": "application/json",
}
body = {
"quality": "draft",
"voice": self.synthesizer_config.voice_id,
"voice": self.synthesizer_config.voice,
"text": message.text,
"sample_rate": self.synthesizer_config.sampling_rate,
"voice_engine": self.synthesizer_config.voice_engine,
}
if self.synthesizer_config.speed:
body["speed"] = self.synthesizer_config.speed
Expand Down