pub struct PiperVoice { /* private fields */ }Expand description
テキストから音声を合成する高レベル API
Implementations§
Source§impl PiperVoice
impl PiperVoice
Sourcepub fn load(
model_path: &Path,
config_path: Option<&Path>,
device: &str,
) -> Result<Self, PiperError>
pub fn load( model_path: &Path, config_path: Option<&Path>, device: &str, ) -> Result<Self, PiperError>
モデルとconfigを読み込んで初期化
phoneme_type に基づいて適切な Phonemizer を自動選択:
- OpenJTalk → JapanesePhonemizer (feature = “japanese”)
- Bilingual/Multilingual → MultilingualPhonemizer (Unicode言語検出)
Sourcepub fn create_phonemizer(
config: &VoiceConfig,
model_dir: Option<&Path>,
) -> Result<Box<dyn Phonemizer>, PiperError>
pub fn create_phonemizer( config: &VoiceConfig, model_dir: Option<&Path>, ) -> Result<Box<dyn Phonemizer>, PiperError>
phoneme_type に基づいて Phonemizer を生成する。
model_dir はモデルファイルの親ディレクトリ。辞書ファイルの検索に使用。
テスト容易性のため独立関数として切り出し。
--test-mode (CLI) で ONNX エンジンなしに phonemizer のみ使用する場合にも利用。
Sourcepub fn synthesize_text(
&mut self,
text: &str,
speaker_id: Option<i64>,
language_override: Option<&str>,
noise_scale: f32,
length_scale: f32,
noise_w: f32,
) -> Result<SynthesisResult, PiperError>
pub fn synthesize_text( &mut self, text: &str, speaker_id: Option<i64>, language_override: Option<&str>, noise_scale: f32, length_scale: f32, noise_w: f32, ) -> Result<SynthesisResult, PiperError>
テキストを音声に変換
language_override を指定すると、phonemizer の自動検出を上書きして
指定言語の language_id を使用する。多言語モデルで特定言語を強制する場合に使用。
Sourcepub fn phonemize_to_ids(&self, text: &str) -> Result<Vec<i64>, PiperError>
pub fn phonemize_to_ids(&self, text: &str) -> Result<Vec<i64>, PiperError>
テキストを音素化して phoneme IDs を返す (ONNX 推論なし)
--test-mode (CI用) で phonemization パイプラインのみ検証する場合に使用。
Sourcepub fn text_to_wav_file(
&mut self,
text: &str,
output: &Path,
speaker_id: Option<i64>,
) -> Result<SynthesisResult, PiperError>
pub fn text_to_wav_file( &mut self, text: &str, output: &Path, speaker_id: Option<i64>, ) -> Result<SynthesisResult, PiperError>
テキストを WAV ファイルに出力 (デフォルトパラメータ使用)
Sourcepub fn config(&self) -> &VoiceConfig
pub fn config(&self) -> &VoiceConfig
config への参照を返す
Sourcepub fn engine(&self) -> &OnnxEngine
pub fn engine(&self) -> &OnnxEngine
engine への参照を返す
Auto Trait Implementations§
impl Freeze for PiperVoice
impl !RefUnwindSafe for PiperVoice
impl Send for PiperVoice
impl Sync for PiperVoice
impl Unpin for PiperVoice
impl UnsafeUnpin for PiperVoice
impl !UnwindSafe for PiperVoice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more