pub struct Elevenlabs {
pub auth: Auth,
pub api_url: String,
/* private fields */
}
Fields§
§auth: Auth
§api_url: String
Implementations§
Source§impl Elevenlabs
impl Elevenlabs
Sourcepub fn new(auth: Auth, api_url: &str) -> Elevenlabs
pub fn new(auth: Auth, api_url: &str) -> Elevenlabs
Examples found in repository?
examples/tts.rs (line 11)
7fn main() {
8 // Load API key from environment ELEVENLABS_API_KEY.
9 // You can also hadcode through `Auth::new(<your_api_key>)`, but it is not recommended.
10 let auth = Auth::from_env().unwrap();
11 let elevenlabs = Elevenlabs::new(auth, "https://api.elevenlabs.io/v1/");
12
13 // Create the tts body.
14 let tts_body = TtsBody {
15 model_id: None,
16 text: "Hello world".to_string(),
17 voice_settings: None,
18 };
19
20 // Generate the speech for the text by using the voice with id yoZ06aMxZJJ28mfd3POQ.
21 let tts_result = elevenlabs.tts(&tts_body, "yoZ06aMxZJJ28mfd3POQ");
22 let bytes = tts_result.unwrap();
23
24 // Do what you need with the bytes.
25 // The server responds with "audio/mpeg" so we can save as mp3.
26 std::fs::write("tts.mp3", bytes).unwrap();
27}
Trait Implementations§
Source§impl Clone for Elevenlabs
impl Clone for Elevenlabs
Source§fn clone(&self) -> Elevenlabs
fn clone(&self) -> Elevenlabs
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Elevenlabs
impl Debug for Elevenlabs
Auto Trait Implementations§
impl Freeze for Elevenlabs
impl !RefUnwindSafe for Elevenlabs
impl Send for Elevenlabs
impl Sync for Elevenlabs
impl Unpin for Elevenlabs
impl !UnwindSafe for Elevenlabs
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