Skip to content

Commit

Permalink
add ability to choose model file
Browse files Browse the repository at this point in the history
  • Loading branch information
rjheeta committed Jun 13, 2024
1 parent 085b71e commit e2888ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vocode/streaming/models/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,4 @@ class CartesiaSynthesizerConfig(SynthesizerConfig, type=SynthesizerType.CARTESIA
class OrcaSynthesizerConfig(SynthesizerConfig, type=SynthesizerType.ORCA.value): # type: ignore
api_key: Optional[str] = None
speech_rate: Optional[float] = None
model_file = DEFAULT_ORCA_MODEL
model_file: str = DEFAULT_ORCA_MODEL
12 changes: 11 additions & 1 deletion vocode/streaming/synthesizer/orca_synthesizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import os
import wave
import hashlib
import struct
Expand Down Expand Up @@ -34,7 +35,16 @@ def __init__(
if synthesizer_config.speech_rate and not (0.7 <= synthesizer_config.speech_rate <= 1.3):
raise ValueError("Speech rate must be between 0.7 and 1.3 inclusive")

self.orca = self.orca_lib.create(access_key=self.api_key)
if synthesizer_config.model_file:
# By default, model files are stored in the same directory as the Orca library
self.model_path = os.path.join(
os.path.dirname(self.orca_lib.default_model_path()),
synthesizer_config.model_file
)
else:
self.model_path = None

self.orca = self.orca_lib.create(access_key=self.api_key, model_path=self.model_path)
self.speech_rate = synthesizer_config.speech_rate
self.sample_rate = SamplingRate.RATE_22050.value # The only rate supported
self.output_format = "pcm" # The only format supported
Expand Down

0 comments on commit e2888ea

Please sign in to comment.