Views
No views yet
outetts library from NPM with:npm i outetts1import { HFModelConfig_v1, InterfaceHF } from "outetts";
2
3// Configure the model
4const model_config = new HFModelConfig_v1({
5 model_path: "onnx-community/OuteTTS-0.2-500M",
6 language: "en", // Supported languages in v0.2: en, zh, ja, ko
7 dtype: "fp32", // Supported dtypes: "fp32", "fp16", "q8", "q4", "q4f16"
8 // device: "wasm", // Supported devices: "webgpu", "wasm" (browser) or "cpu", "cuda", "dml" (Node.js, OS-specific)
9});
10
11// Initialize the interface
12const tts_interface = await InterfaceHF({ model_version: "0.2", cfg: model_config });
13
14// Print available default speakers
15tts_interface.print_default_speakers();
16
17// Load a default speaker
18const speaker = tts_interface.load_default_speaker("male_1");
19
20// Generate speech
21const output = await tts_interface.generate({
22 text: "Speech synthesis is the artificial production of human speech.",
23 temperature: 0.1, // Lower temperature values may result in a more stable tone
24 repetition_penalty: 1.1,
25 max_length: 4096,
26
27 // Optional: Use a speaker profile for consistent voice characteristics
28 // Without a speaker profile, the model will generate a voice with random characteristics
29 speaker,
30});
31
32// Save the synthesized speech to a file
33output.save("output.wav");