pub struct PiperEncoder { /* private fields */ }Expand description
High-level encoder that converts IPA token sequences into Piper-compatible phoneme ID arrays with BOS/EOS/PAD insertion.
Implementations§
Source§impl PiperEncoder
impl PiperEncoder
Sourcepub fn new(
id_map: PhonemeIdMap,
mode: UnknownTokenMode,
) -> Result<Self, G2pError>
pub fn new( id_map: PhonemeIdMap, mode: UnknownTokenMode, ) -> Result<Self, G2pError>
Create a new encoder from a phoneme ID map.
Sourcepub fn encode(&self, tokens: &[String]) -> Result<Vec<i64>, G2pError>
pub fn encode(&self, tokens: &[String]) -> Result<Vec<i64>, G2pError>
Encode IPA tokens to phoneme IDs with BOS/EOS/PAD insertion.
Sourcepub fn encode_with_eos(
&self,
tokens: &[String],
eos_token: Option<&str>,
) -> Result<Vec<i64>, G2pError>
pub fn encode_with_eos( &self, tokens: &[String], eos_token: Option<&str>, ) -> Result<Vec<i64>, G2pError>
Encode IPA tokens with a custom EOS token.
eos_token = None→ default EOS ("$")eos_token = Some("?")→ look up"?"in id_mapeos_token = Some("?!")→ look up PUA-mapped"?!"in id_map
Sourcepub fn encode_with_prosody(
&self,
tokens: &[String],
prosody: &[Option<ProsodyInfo>],
) -> Result<(Vec<i64>, Vec<ProsodyFeature>), G2pError>
pub fn encode_with_prosody( &self, tokens: &[String], prosody: &[Option<ProsodyInfo>], ) -> Result<(Vec<i64>, Vec<ProsodyFeature>), G2pError>
Encode IPA tokens with prosody alignment.
Sourcepub fn encode_with_prosody_and_eos(
&self,
tokens: &[String],
prosody: &[Option<ProsodyInfo>],
eos_token: Option<&str>,
) -> Result<(Vec<i64>, Vec<ProsodyFeature>), G2pError>
pub fn encode_with_prosody_and_eos( &self, tokens: &[String], prosody: &[Option<ProsodyInfo>], eos_token: Option<&str>, ) -> Result<(Vec<i64>, Vec<ProsodyFeature>), G2pError>
Encode IPA tokens with prosody alignment and a custom EOS token.
Auto Trait Implementations§
impl Freeze for PiperEncoder
impl RefUnwindSafe for PiperEncoder
impl Send for PiperEncoder
impl Sync for PiperEncoder
impl Unpin for PiperEncoder
impl UnsafeUnpin for PiperEncoder
impl UnwindSafe for PiperEncoder
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