VoiceRSSOptions

Struct VoiceRSSOptions 

Source
pub struct VoiceRSSOptions { /* private fields */ }
Expand description

§Example usage:

use tts_urls::voicerss::{VoiceRSSOptions, Language, Codec};
let key = "key";

let url = VoiceRSSOptions::new()
    .language(Language::German)
    .audio_format("32khz_16bit_stereo")
    .codec(Codec::MP3)
    .url(key, "Hallo Welt!");
assert_eq!(url, "http://api.voicerss.org/?key=key&hl=de-de&c=MP3&f=32khz_16bit_stereo&src=Hallo%20Welt%21");

Implementations§

Source§

impl VoiceRSSOptions

Source

pub fn new() -> Self

Examples found in repository?
examples/voicerss.rs (line 6)
3fn main() {
4    let key = std::env::var("VOICERSS_API_KEY").expect("no api key");
5
6    let url = VoiceRSSOptions::new()
7        .codec(Codec::MP3)
8        .voice("Alice")
9        .url(&key, "This is a test");
10
11    println!("{}", url);
12}
Source

pub fn language(&mut self, language: Language) -> &mut Self

see VoiceRSS documentation for possible values

Source

pub fn voice(&mut self, voice: impl Into<Cow<'static, str>>) -> &mut Self

see VoiceRSS documentation for possible values

Examples found in repository?
examples/voicerss.rs (line 8)
3fn main() {
4    let key = std::env::var("VOICERSS_API_KEY").expect("no api key");
5
6    let url = VoiceRSSOptions::new()
7        .codec(Codec::MP3)
8        .voice("Alice")
9        .url(&key, "This is a test");
10
11    println!("{}", url);
12}
Source

pub fn speed(&mut self, speed: i8) -> &mut Self

The speech rate. Allows values from -10 to 10.

Source

pub fn codec(&mut self, codec: Codec) -> &mut Self

see VoiceRSS documentation for possible values

Examples found in repository?
examples/voicerss.rs (line 7)
3fn main() {
4    let key = std::env::var("VOICERSS_API_KEY").expect("no api key");
5
6    let url = VoiceRSSOptions::new()
7        .codec(Codec::MP3)
8        .voice("Alice")
9        .url(&key, "This is a test");
10
11    println!("{}", url);
12}
Source

pub fn audio_format( &mut self, audio_format: impl Into<Cow<'static, str>>, ) -> &mut Self

see [www.voicerss.org/api/documentation.aspx](VoiceRSS documentation for possible values)

Source

pub fn ssml(&mut self, ssml: bool) -> &mut Self

Enable the SSML textual content format

Source

pub fn base64(&mut self, base64: bool) -> &mut Self

makes the VoiceRSS api return the inline base64 src for an HTML

Source

pub fn url(&self, key: &str, text: &str) -> String

Returns the URL to the TTS audio for the given term and api key.

Examples found in repository?
examples/voicerss.rs (line 9)
3fn main() {
4    let key = std::env::var("VOICERSS_API_KEY").expect("no api key");
5
6    let url = VoiceRSSOptions::new()
7        .codec(Codec::MP3)
8        .voice("Alice")
9        .url(&key, "This is a test");
10
11    println!("{}", url);
12}

Trait Implementations§

Source§

impl Default for VoiceRSSOptions

Source§

fn default() -> VoiceRSSOptions

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> 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, 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.