aristech-tts-client 1.0.0

A Rust client library for the Aristech Text-to-Speech API
Documentation

Aristech TTS-Client for Rust

This is the Rust client implementation for the Aristech TTS-Server.

Installation

Add the following to your Cargo.toml:

[dependencies]
aristech_tts_client = "1.0.0"

Usage

let client = get_client(
  "https://tts.example.com",
  Some(TlsOptions { ca_certificate: None, auth: None }),
).await?;

let request = SpeechRequest {
  text: "Text to speak.".to_string(),
  options: Some(SpeechRequestOption {
    voice_id: "anne_en_GB".to_string(),
    ..SpeechRequestOption::default()
  }),
  ..SpeechRequest::default()
};
let data = get_audio(&mut client, request).await?;
std::fs::write("output.wav", data).expect("Unable to write file");

There are several examples in the examples directory:

  • file.rs: Demonstrates how convert text to speech and save the audio to a file.
  • streaming.rs: Demonstrates how to stream audio to a sox process which plays the audio as it is being streamed.
  • voices.rs: Demonstrates how to get the available voices from the server.
  • phoneset.rs: Demonstrates how to retrieve the phoneset for a voice.
  • transcribe.rs: Demonstrates how to retrieve the pronunciation of a word for a voice.

You can run the examples directly using cargo like this:

  1. Create a .env file in the rust directory:
HOST=https://tts.example.com # Note: The protocol is required in the rust client
# The credentials are optional but probably required for most servers:
TOKEN=your-token
SECRET=your-secret

# The following are optional:
# ROOT_CERT=your-root-cert.pem # If the server uses a self-signed certificate
# SSL=true # Set to true if credentials are provided or if a ROOT_CERT is provided
# VOICE_ID=some-available-voice-id
  1. Run the examples, e.g.:
cargo run --example file

Build

To build the library, run:

cargo build