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

# Semantic Kernel

> Use Lokutor text-to-speech and speech-to-text through Semantic Kernel's OpenAI audio connectors.

Semantic Kernel's OpenAI audio connectors accept a pre-built client, so a base URL override is enough.

## Python

```python theme={null}
from openai import AsyncOpenAI
from semantic_kernel.connectors.ai.open_ai import (
    OpenAIAudioToText, OpenAIAudioToTextExecutionSettings,
    OpenAITextToAudio, OpenAITextToAudioExecutionSettings)
from semantic_kernel.contents import AudioContent

client = AsyncOpenAI(api_key=os.environ["LOKUTOR_API_KEY"], base_url="https://api.lokutor.com/v1")
tts = OpenAITextToAudio(ai_model_id="tts-1", async_client=client)
stt = OpenAIAudioToText(ai_model_id="whisper-1", async_client=client)

audio = await tts.get_audio_contents(
    "Hello from Lokutor.", OpenAITextToAudioExecutionSettings(voice="alloy", response_format="wav"))
open("out.wav", "wb").write(audio[0].data)
text = await stt.get_text_contents(
    AudioContent.from_audio_file("out.wav"), OpenAIAudioToTextExecutionSettings(language="en"))
```

Notes: the Python `voice` field only accepts OpenAI voice names, which Lokutor maps onto its voices (`alloy` and the
others map onto F1-F5 / M1-M5). Audio is always WAV and STT takes WAV only.

Verified against the live API (TTS to STT round trip) with the `semantic-kernel` Python package. Runnable copy:
[lokutor-ai/openai-compatible-examples](https://github.com/lokutor-ai/openai-compatible-examples/tree/main/semantic-kernel-python).

## .NET

`OpenAITextToAudioService` and `OpenAIAudioToTextService` take an `OpenAIClient`; build it with
`new OpenAIClientOptions { Endpoint = new Uri("https://api.lokutor.com/v1") }` and your Lokutor key. **Not run:** the .NET
connectors were not tested.


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