Skip to main content

TTSQueueInput

Struct TTSQueueInput 

Source
pub struct TTSQueueInput<T>
where T: Source + Send + Clone,
{ pub sounds: Mutex<Vec<(T, Option<Sender<bool>>)>>, pub is_finished: AtomicBool, }
Expand description

TTS队列输入端

用于向TTS队列中添加音频片段。该结构是线程安全的,可以跨线程使用。

§泛型参数

  • T - 音频源类型,必须实现Source、Send和Clone trait

Fields§

§sounds: Mutex<Vec<(T, Option<Sender<bool>>)>>

存储音频片段的向量,每个片段可以附带一个信号发送器 使用Mutex保证线程安全

§is_finished: AtomicBool

标记队列是否已完成(不再添加新的音频片段) 使用AtomicBool保证原子操作

Implementations§

Source§

impl<T> TTSQueueInput<T>
where T: Source + Send + Clone,

Source

pub fn append(&self, source: T)

向队列末尾添加一个音频片段

§参数
  • source - 要添加的音频源
Source

pub fn append_with_signal(&self, source: T) -> Receiver<bool>

向队列末尾添加一个带信号通知的音频片段

返回一个接收器,用于接收该音频片段的播放状态通知:

  • false: 音频片段开始播放
  • true: 音频片段播放完成
§参数
  • source - 要添加的音频源
§返回值
  • Receiver<bool> - 用于接收播放状态通知的接收器
Source

pub fn set_is_finished(&self, is_finished: bool)

设置队列完成状态

当设置为true时,表示不会再有新的音频片段添加到队列中

§参数
  • is_finished - 完成状态标志
Source

pub fn is_finished(&self) -> bool

检查队列是否已完成

§返回值
  • bool - 如果队列已完成返回true,否则返回false

Auto Trait Implementations§

§

impl<T> !Freeze for TTSQueueInput<T>

§

impl<T> RefUnwindSafe for TTSQueueInput<T>

§

impl<T> Send for TTSQueueInput<T>

§

impl<T> Sync for TTSQueueInput<T>

§

impl<T> Unpin for TTSQueueInput<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TTSQueueInput<T>

§

impl<T> UnwindSafe for TTSQueueInput<T>

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more