> ## 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.

# टेक्स्ट-टू-स्पीच / स्पीच-टू-टेक्स्ट (AI SDK)

> Phaseo provider models से speech-to-text (STT) और text-to-speech (TTS)।

`transcriptionModel` के साथ `experimental_transcribe` और `speechModel` के साथ `experimental_generateSpeech` उपयोग करें।

```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);
```

## नोट्स

* AI SDK के मौजूदा audio helpers अभी experimental हैं; upstream stable APIs आने पर इनके नाम बदल सकते हैं।
* Audio input/output formats model के अनुसार अलग होते हैं।
* लंबी files के अनुसार payload sizes और timeouts सेट करें।
* अस्थायी `429` और `5xx` responses पर retry करें।


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