Skip to main content

VoiceCondition

Struct VoiceCondition 

Source
pub struct VoiceCondition {
    pub speaker_audio: Option<AudioInput>,
    pub cached_voice_id: Option<String>,
    pub language: Option<String>,
    pub emotion: Option<String>,
    pub speaking_rate: Option<f32>,
    pub pitch_shift: Option<f32>,
    pub energy_scale: Option<f32>,
    pub tags: BTreeMap<String, String>,
}
Expand description

说话人参考 / 风格条件(映射到上游请求 JSON 的 voice 字段)。

比把参考音频塞进顶层 audio 更语义化:支持「用参考音频克隆音色」、 「用 cached_voice_id 复用已注册音色」、以及风格/语速/音高控制。 通过 TtsRequest::voice 设置。

Fields§

§speaker_audio: Option<AudioInput>

说话人参考音频(声音克隆)。

§cached_voice_id: Option<String>

已缓存的音色 id(复用之前克隆得到的音色,免去再次上传参考音频)。

§language: Option<String>

风格:语言。

§emotion: Option<String>

风格:情绪。

§speaking_rate: Option<f32>

风格:语速缩放。

§pitch_shift: Option<f32>

风格:音高偏移。

§energy_scale: Option<f32>

风格:能量缩放。

§tags: BTreeMap<String, String>

风格:自由标签。

Implementations§

Source§

impl VoiceCondition

Source

pub fn speaker(audio: impl Into<AudioInput>) -> Self

以说话人参考音频(声音克隆)构造。

Source

pub fn cached(id: impl Into<String>) -> Self

以已缓存音色 id 构造(复用音色)。

Source

pub fn language(self, language: impl Into<String>) -> Self

设置语言。

Source

pub fn emotion(self, emotion: impl Into<String>) -> Self

设置情绪。

Source

pub fn speaking_rate(self, rate: f32) -> Self

设置语速缩放。

Source

pub fn pitch_shift(self, shift: f32) -> Self

设置音高偏移。

Source

pub fn energy_scale(self, scale: f32) -> Self

设置能量缩放。

Source

pub fn tag(self, key: impl Into<String>, value: impl Into<String>) -> Self

设置一个风格标签。

Trait Implementations§

Source§

impl Clone for VoiceCondition

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VoiceCondition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VoiceCondition

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.