Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

Remove tts examples and mentions in readme (#653)

uuuvn305c8391f5d9
diff --git a/README.md b/README.md
index 7412bc18d..f916337f1 100644
--- a/README.md
+++ b/README.md
@@ -232,7 +232,7 @@ Everything from model downloading to inference configuration is handled automati
## Examples
-You can run any example via `cargo tools example` \<**rust** | **python** | **swift** | **typescript**\> \<**chat** | **chat-cloud** | **chat-structured-output** | **classification** | **quick-start** | **text-to-speech**\>:
+You can run any example via `cargo tools example` \<**rust** | **python** | **swift** | **typescript**\> \<**chat** | **chat-cloud** | **chat-structured-output** | **classification** | **quick-start**\>:
### Chat
@@ -947,179 +947,6 @@ main().catch((error) => {
</details>
-### Text to Speech
-
-In this example, we will generate audio from text:
-
-<details>
-<summary>Rust</summary>
-
-```rust
-use uzu::{
- engine::{Engine, EngineConfig},
- session::text_to_speech::TextToSpeechSessionStreamChunk,
- types::basic::PcmBatch,
-};
-
-#[tokio::main]
-async fn main() -> Result<(), Box<dyn std::error::Error>> {
- let engine_config = EngineConfig::default();
- let engine = Engine::new(engine_config).await?;
-
- let model = engine.model("fishaudio/s1-mini".to_string()).await?.ok_or("Model not found")?;
- let downloader = engine.download(&model).await?;
- while let Some(update) = downloader.next().await {
- println!("Download progress: {}", update.progress());
- }
-
- let text = "London is the capital of United Kingdom and one of the world's most influential cities, \
- known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. \
- Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace \
- with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum \
- and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year.";
- let output_path = dirs::home_dir().ok_or("Home not found")?.join("Desktop").join("output.wav");
-
- let session = engine.text_to_speech(model).await?;
- let stream = session.synthesize_stream(text.to_string()).await;
- let mut pcm_batches: Vec<PcmBatch> = Vec::new();
- while let Some(event) = stream.next().await {
- match event {
- TextToSpeechSessionStreamChunk::Output {
- output,
- } => {
- pcm_batches.push(output.pcm_batch);
- },
- TextToSpeechSessionStreamChunk::Error {
- error,
- } => {
- println!("Error: {error}");
- },
- }
- }
-
- let pcm_batch_first = pcm_batches.first().ok_or("No batches")?;
- let pcm_batch_full = PcmBatch {
- samples: pcm_batches.iter().flat_map(|batch| batch.samples.iter().copied()).collect(),
- sample_rate: pcm_batch_first.sample_rate,
- channels: pcm_batch_first.channels,
- lengths: vec![pcm_batches.iter().flat_map(|batch| batch.lengths.iter().copied()).sum()],
- };
- pcm_batch_full.save_as_wav(output_path.to_string_lossy().to_string())?;
- println!("Output saved to: {}", output_path.display());
-
- Ok(())
-}
-```
-
-</details>
-
-<details>
-<summary>Python</summary>
-
-```python
-import asyncio
-from pathlib import Path
-
-from uzu import Engine, EngineConfig
-
-
-async def main() -> None:
- engine_config = EngineConfig.create()
- engine = await Engine.create(engine_config)
-
- model = await engine.model("fishaudio/s1-mini")
- if model is None:
- raise RuntimeError("Model not found")
- async for update in (await engine.download(model)).iterator():
- print(f"Download progress: {update.progress}")
-
- text = (
- "London is the capital of United Kingdom and one of the world's most influential cities, "
- "known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. "
- "Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace "
- "with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum "
- "and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year."
- )
- output_path = Path.home() / "Desktop" / "output.wav"
- session = await engine.text_to_speech(model)
- output = await session.synthesize(text)
- output.pcm_batch.save_as_wav(str(output_path))
- print(f"Output saved to: {output_path}")
-
-
-if __name__ == "__main__":
- asyncio.run(main())
-```
-
-</details>
-
-<details>
-<summary>Swift</summary>
-
-```swift
-import Foundation
-import Uzu
-
-public func runTextToSpeech() async throws {
- let engineConfig = EngineConfig.create()
- let engine = try await Engine.create(config: engineConfig)
-
- guard let model = try await engine.model(identifier: "fishaudio/s1-mini") else {
- return
- }
- for try await update in try await engine.download(model: model).iterator() {
- print("Download progress: \(update.progress())")
- }
-
- let text = "London is the capital of United Kingdom and one of the world’s most influential cities, known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year."
- let outputPath = FileManager.default.homeDirectoryForCurrentUser
- .appendingPathComponent("Desktop")
- .appendingPathComponent("output.wav")
- let session = try await engine.textToSpeech(model: model)
- let output = try await session.synthesize(input: text)
- try output.pcmBatch.saveAsWav(path: outputPath.path())
- print("Output saved to: \(outputPath.path())")
-}
-```
-
-</details>
-
-<details>
-<summary>TypeScript</summary>
-
-```ts
-import { Engine, EngineConfig } from '@trymirai/uzu';
-import { homedir } from "os";
-import { join } from "path";
-
-async function main() {
- let engineConfig = EngineConfig.create();
- let engine = await Engine.create(engineConfig);
-
- let model = await engine.model('fishaudio/s1-mini');
- if (!model) {
- throw new Error('Model not found');
- }
- for await (const update of await engine.download(model)) {
- console.log('Download progress:', update.progress);
- }
-
- const text = "London is the capital of United Kingdom and one of the world’s most influential cities, known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year.";
- const outputPath = join(homedir(), "Desktop", "output.wav");
- let session = await engine.textToSpeech(model);
- let output = await session.synthesize(text);
- output.pcmBatch.saveAsWav(outputPath);
- console.log('Output saved to: ', outputPath);
-}
-
-main().catch((error) => {
- console.error(error);
-});
-```
-
-</details>
-
-
## Development
diff --git a/bindings/python/README.md b/bindings/python/README.md
index e47148a4d..2412cb1f9 100644
--- a/bindings/python/README.md
+++ b/bindings/python/README.md
@@ -72,7 +72,7 @@ Everything from model downloading to inference configuration is handled automati
## Examples
-You can run any example via `cargo tools example` \<**python**\> \<**chat** | **chat-cloud** | **chat-structured-output** | **classification** | **quick-start** | **text-to-speech**\>:
+You can run any example via `cargo tools example` \<**python**\> \<**chat** | **chat-cloud** | **chat-structured-output** | **classification** | **quick-start**\>:
### Chat
@@ -262,45 +262,6 @@ if __name__ == "__main__":
asyncio.run(main())
```
-### Text to Speech
-
-In this example, we will generate audio from text:
-
-```python
-import asyncio
-from pathlib import Path
-
-from uzu import Engine, EngineConfig
-
-
-async def main() -> None:
- engine_config = EngineConfig.create()
- engine = await Engine.create(engine_config)
-
- model = await engine.model("fishaudio/s1-mini")
- if model is None:
- raise RuntimeError("Model not found")
- async for update in (await engine.download(model)).iterator():
- print(f"Download progress: {update.progress}")
-
- text = (
- "London is the capital of United Kingdom and one of the world's most influential cities, "
- "known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. "
- "Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace "
- "with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum "
- "and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year."
- )
- output_path = Path.home() / "Desktop" / "output.wav"
- session = await engine.text_to_speech(model)
- output = await session.synthesize(text)
- output.pcm_batch.save_as_wav(str(output_path))
- print(f"Output saved to: {output_path}")
-
-
-if __name__ == "__main__":
- asyncio.run(main())
-```
-
## Troubleshooting
diff --git a/bindings/python/examples/text_to_speech.py b/bindings/python/examples/text_to_speech.py
deleted file mode 100644
index 326337286..000000000
--- a/bindings/python/examples/text_to_speech.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import asyncio
-from pathlib import Path
-
-from uzu import Engine, EngineConfig
-
-
-async def main() -> None:
- engine_config = EngineConfig.create()
- engine = await Engine.create(engine_config)
-
- model = await engine.model("fishaudio/s1-mini")
- if model is None:
- raise RuntimeError("Model not found")
- async for update in (await engine.download(model)).iterator():
- print(f"Download progress: {update.progress}")
-
- text = (
- "London is the capital of United Kingdom and one of the world's most influential cities, "
- "known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. "
- "Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace "
- "with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum "
- "and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year."
- )
- output_path = Path.home() / "Desktop" / "output.wav"
- session = await engine.text_to_speech(model)
- output = await session.synthesize(text)
- output.pcm_batch.save_as_wav(str(output_path))
- print(f"Output saved to: {output_path}")
-
-
-if __name__ == "__main__":
- asyncio.run(main())
diff --git a/bindings/swift/README.md b/bindings/swift/README.md
index f8a0c2411..295f89bc7 100644
--- a/bindings/swift/README.md
+++ b/bindings/swift/README.md
@@ -69,7 +69,7 @@ Everything from model downloading to inference configuration is handled automati
## Examples
-You can run any example via `cargo tools example` \<**swift**\> \<**chat** | **chat-cloud** | **chat-structured-output** | **classification** | **quick-start** | **text-to-speech**\>:
+You can run any example via `cargo tools example` \<**swift**\> \<**chat** | **chat-cloud** | **chat-structured-output** | **classification** | **quick-start**\>:
### Chat
@@ -213,36 +213,6 @@ public func runClassification() async throws {
}
```
-### Text to Speech
-
-In this example, we will generate audio from text:
-
-```swift
-import Foundation
-import Uzu
-
-public func runTextToSpeech() async throws {
- let engineConfig = EngineConfig.create()
- let engine = try await Engine.create(config: engineConfig)
-
- guard let model = try await engine.model(identifier: "fishaudio/s1-mini") else {
- return
- }
- for try await update in try await engine.download(model: model).iterator() {
- print("Download progress: \(update.progress())")
- }
-
- let text = "London is the capital of United Kingdom and one of the world’s most influential cities, known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year."
- let outputPath = FileManager.default.homeDirectoryForCurrentUser
- .appendingPathComponent("Desktop")
- .appendingPathComponent("output.wav")
- let session = try await engine.textToSpeech(model: model)
- let output = try await session.synthesize(input: text)
- try output.pcmBatch.saveAsWav(path: outputPath.path())
- print("Output saved to: \(outputPath.path())")
-}
-```
-
## Troubleshooting
diff --git a/bindings/swift/Sources/Examples/CLI.swift b/bindings/swift/Sources/Examples/CLI.swift
index e51545a1b..37885c587 100644
--- a/bindings/swift/Sources/Examples/CLI.swift
+++ b/bindings/swift/Sources/Examples/CLI.swift
@@ -12,7 +12,7 @@ struct Example: AsyncParsableCommand {
@Argument(
help:
- "Mode: chat | chat-for-summarization | chat-for-classification | quick-start | snippets | cloud | ssm | structured-output | classifier | text-to-speech",
+ "Mode: chat | chat-for-summarization | chat-for-classification | quick-start | snippets | cloud | ssm | structured-output | classifier",
transform: { $0.lowercased() })
var mode: String = "chat"
@@ -28,8 +28,6 @@ struct Example: AsyncParsableCommand {
try await runChatStructuredOutput()
case "classification":
try await runClassification()
- case "text-to-speech":
- try await runTextToSpeech()
default:
throw ValidationError("Unknown mode: \(mode)")
}
diff --git a/bindings/swift/Sources/Examples/TextToSpeech.swift b/bindings/swift/Sources/Examples/TextToSpeech.swift
deleted file mode 100644
index 3ad9016b4..000000000
--- a/bindings/swift/Sources/Examples/TextToSpeech.swift
+++ /dev/null
@@ -1,23 +0,0 @@
-import Foundation
-import Uzu
-
-public func runTextToSpeech() async throws {
- let engineConfig = EngineConfig.create()
- let engine = try await Engine.create(config: engineConfig)
-
- guard let model = try await engine.model(identifier: "fishaudio/s1-mini") else {
- return
- }
- for try await update in try await engine.download(model: model).iterator() {
- print("Download progress: \(update.progress())")
- }
-
- let text = "London is the capital of United Kingdom and one of the world’s most influential cities, known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year."
- let outputPath = FileManager.default.homeDirectoryForCurrentUser
- .appendingPathComponent("Desktop")
- .appendingPathComponent("output.wav")
- let session = try await engine.textToSpeech(model: model)
- let output = try await session.synthesize(input: text)
- try output.pcmBatch.saveAsWav(path: outputPath.path())
- print("Output saved to: \(outputPath.path())")
-}
diff --git a/bindings/typescript/README.md b/bindings/typescript/README.md
index c7b8acdae..44551abfd 100644
--- a/bindings/typescript/README.md
+++ b/bindings/typescript/README.md
@@ -72,7 +72,7 @@ Everything from model downloading to inference configuration is handled automati
## Examples
-You can run any example via `cargo tools example` \<**typescript**\> \<**chat** | **chat-cloud** | **chat-structured-output** | **classification** | **quick-start** | **text-to-speech**\>:
+You can run any example via `cargo tools example` \<**typescript**\> \<**chat** | **chat-cloud** | **chat-structured-output** | **classification** | **quick-start**\>:
### Chat
@@ -241,40 +241,6 @@ main().catch((error) => {
});
```
-### Text to Speech
-
-In this example, we will generate audio from text:
-
-```ts
-import { Engine, EngineConfig } from '@trymirai/uzu';
-import { homedir } from "os";
-import { join } from "path";
-
-async function main() {
- let engineConfig = EngineConfig.create();
- let engine = await Engine.create(engineConfig);
-
- let model = await engine.model('fishaudio/s1-mini');
- if (!model) {
- throw new Error('Model not found');
- }
- for await (const update of await engine.download(model)) {
- console.log('Download progress:', update.progress);
- }
-
- const text = "London is the capital of United Kingdom and one of the world’s most influential cities, known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year.";
- const outputPath = join(homedir(), "Desktop", "output.wav");
- let session = await engine.textToSpeech(model);
- let output = await session.synthesize(text);
- output.pcmBatch.saveAsWav(outputPath);
- console.log('Output saved to: ', outputPath);
-}
-
-main().catch((error) => {
- console.error(error);
-});
-```
-
## Troubleshooting
diff --git a/bindings/typescript/examples/textToSpeech.ts b/bindings/typescript/examples/textToSpeech.ts
deleted file mode 100644
index 06bc8d915..000000000
--- a/bindings/typescript/examples/textToSpeech.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Engine, EngineConfig } from '@trymirai/uzu';
-import { homedir } from "os";
-import { join } from "path";
-
-async function main() {
- let engineConfig = EngineConfig.create();
- let engine = await Engine.create(engineConfig);
-
- let model = await engine.model('fishaudio/s1-mini');
- if (!model) {
- throw new Error('Model not found');
- }
- for await (const update of await engine.download(model)) {
- console.log('Download progress:', update.progress);
- }
-
- const text = "London is the capital of United Kingdom and one of the world’s most influential cities, known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year.";
- const outputPath = join(homedir(), "Desktop", "output.wav");
- let session = await engine.textToSpeech(model);
- let output = await session.synthesize(text);
- output.pcmBatch.saveAsWav(outputPath);
- console.log('Output saved to: ', outputPath);
-}
-
-main().catch((error) => {
- console.error(error);
-});
diff --git a/crates/uzu/examples/text_to_speech.rs b/crates/uzu/examples/text_to_speech.rs
deleted file mode 100644
index 0781987e2..000000000
--- a/crates/uzu/examples/text_to_speech.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-use uzu::{
- engine::{Engine, EngineConfig},
- session::text_to_speech::TextToSpeechSessionStreamChunk,
- types::basic::PcmBatch,
-};
-
-#[tokio::main]
-async fn main() -> Result<(), Box<dyn std::error::Error>> {
- let engine_config = EngineConfig::default();
- let engine = Engine::new(engine_config).await?;
-
- let model = engine.model("fishaudio/s1-mini".to_string()).await?.ok_or("Model not found")?;
- let downloader = engine.download(&model).await?;
- while let Some(update) = downloader.next().await {
- println!("Download progress: {}", update.progress());
- }
-
- let text = "London is the capital of United Kingdom and one of the world's most influential cities, \
- known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. \
- Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace \
- with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum \
- and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year.";
- let output_path = dirs::home_dir().ok_or("Home not found")?.join("Desktop").join("output.wav");
-
- let session = engine.text_to_speech(model).await?;
- let stream = session.synthesize_stream(text.to_string()).await;
- let mut pcm_batches: Vec<PcmBatch> = Vec::new();
- while let Some(event) = stream.next().await {
- match event {
- TextToSpeechSessionStreamChunk::Output {
- output,
- } => {
- pcm_batches.push(output.pcm_batch);
- },
- TextToSpeechSessionStreamChunk::Error {
- error,
- } => {
- println!("Error: {error}");
- },
- }
- }
-
- let pcm_batch_first = pcm_batches.first().ok_or("No batches")?;
- let pcm_batch_full = PcmBatch {
- samples: pcm_batches.iter().flat_map(|batch| batch.samples.iter().copied()).collect(),
- sample_rate: pcm_batch_first.sample_rate,
- channels: pcm_batch_first.channels,
- lengths: vec![pcm_batches.iter().flat_map(|batch| batch.lengths.iter().copied()).sum()],
- };
- pcm_batch_full.save_as_wav(output_path.to_string_lossy().to_string())?;
- println!("Output saved to: {}", output_path.display());
-
- Ok(())
-}
diff --git a/platforms.toml b/platforms.toml
index 65bed0afd..63428c789 100644
--- a/platforms.toml
+++ b/platforms.toml
@@ -177,4 +177,3 @@ chat = { title = "Chat", description = "In this example, we will download a mode
chat-cloud = { title = "Chat with the cloud model", description = "In this example, we will get a reply to a specific list of messages from a cloud model:" }
chat-structured-output = { title = "Chat with structured output", description = "Sometimes you want the generated output to be valid JSON with predefined fields. You can use `Grammar` to manually specify a JSON schema for the response you want to receive:" }
classification = { title = "Classification", description = "In this example, we will use a classification model to determine whether the user's input is safe from a moderation perspective:" }
-text-to-speech = { title = "Text to Speech", description = "In this example, we will generate audio from text:" }