> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# TTS / STT (Text-zu-Sprache / Sprache-zu-Text, AI SDK)

> Sprache-zu-Text (STT) und Text-zu-Sprache (TTS) mit Phaseo-Providermodellen.

Verwende `experimental_transcribe` mit `transcriptionModel` und `experimental_generateSpeech` mit `speechModel`.

```ts theme={null}
import { readFileSync, writeFileSync } from "node:fs";
import { phaseo } from "@phaseo/ai-sdk-provider";
import { experimental_generateSpeech, experimental_transcribe } from "ai";

const audioInput = readFileSync("./audio.mp3");

const transcription = await experimental_transcribe({
  model: phaseo.transcriptionModel("openai/whisper-1"),
  audioData: new Blob([audioInput], { type: "audio/mpeg" }),
});

console.log(transcription.text);
console.log(transcription.providerMetadata);

const speech = await experimental_generateSpeech({
  model: phaseo.speechModel("openai/tts-1"),
  text: "Hello from Phaseo audio.",
  voice: "alloy",
  outputFormat: "mp3",
});

writeFileSync("./speech.mp3", Buffer.from(speech.audio.uint8Array));
console.log(speech.providerMetadata);
```

## Hinweise

* Die aktuellen Audio-Hilfen von AI SDK sind noch experimentell. Ihre Namen können sich ändern, sobald die stabilen Upstream-APIs verfügbar sind.
* Audio-Eingabe- und -Ausgabeformate sind modellspezifisch.
* Stimme Payload-Größen und Timeouts auf lange Dateien ab.
* Wiederhole Anfragen nach vorübergehenden `429`- und `5xx`-Antworten.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.