pub struct Auth {
pub api_key: String,
}Fields§
§api_key: StringImplementations§
Source§impl Auth
impl Auth
pub fn new(api_key: &str) -> Auth
Sourcepub fn from_env() -> Result<Self, String>
pub fn from_env() -> Result<Self, String>
Examples found in repository?
examples/tts.rs (line 10)
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<'de> Deserialize<'de> for Auth
impl<'de> Deserialize<'de> for Auth
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Auth
impl RefUnwindSafe for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl UnwindSafe for Auth
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