> For the complete documentation index, see [llms.txt](https://micup.renbow.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://micup.renbow.dev/ses.md).

# Ses

## Önemli bilgi

Ses kanalına girmek iki adımdan oluşur:

1. Sunucu botun ses bağlantısı için bir "grant" (token ve endpoint) verir.
2. Bot bu bilgiyle LiveKit odasına bağlanır.

Botun ses kanalında görünmesi için LiveKit bağlantısı gerekir. Bu kütüphane 2. adımı `join()` içinde kendisi yapar. Medya kurulumunu test ettiğimizde bot, LiveKit bağlantısı kurulduktan sonra kanalda göründü.

## `await bot.voice.join(guild_id, channel_id, *, self_mute=False, self_deaf=False, self_video=False, timeout=15.0, state_timeout=60.0, media=True)`

| Parametre       | Varsayılan | Açıklama                                                                                                 |
| --------------- | ---------- | -------------------------------------------------------------------------------------------------------- |
| `guild_id`      | —          | Sunucu ID'si                                                                                             |
| `channel_id`    | —          | Ses kanalı ID'si                                                                                         |
| `self_mute`     | `False`    | Başlangıçta mikrofon kapalı mı                                                                           |
| `self_deaf`     | `False`    | Başlangıçta kulaklık kapalı mı                                                                           |
| `self_video`    | `False`    | Video durumu. Video yayınlanmaz, sadece durum bildirilir.                                                |
| `timeout`       | `15.0`     | Sunucudan grant gelmesini bekleme süresi (sn). Dolarsa `VOICE_TIMEOUT` fırlatır.                         |
| `state_timeout` | `60.0`     | Botun kendi ses durumu gelmesini bekleme süresi (sn). Dolarsa uyarı yazar ve devam eder, hata fırlatmaz. |
| `media`         | `True`     | LiveKit odasına bağlanılsın mı. `False` ise sadece grant alınır.                                         |

Akış:

1. Katılma isteği (op 4) gönderilir.
2. Grant beklenir (`timeout`).
3. `media=True` ise LiveKit odasına bağlanılır. Bağlantı için `livekit` paketi gerekir, yoksa `LIVEKIT_MISSING` fırlatılır.
4. Botun ses durumu beklenir (`state_timeout`).

Dönüş değeri:

```python
{
    "guild_id": "...",
    "channel_id": "...",
    "connection_id": "...",
    "session_id": "...",   # bilinmiyorsa None
    "endpoint": "wss://...",
    "token": "...",
}
```

## Diğer ses metotları

| Metot                                                                               | Dönüş        | Açıklama                                                                                    |
| ----------------------------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------- |
| `bot.voice.get_states(guild_id)`                                                    | `List[dict]` | Sunucudaki bilinen ses durumları.                                                           |
| `await bot.voice.update(guild_id, self_mute=None, self_deaf=None, self_video=None)` | `None`       | Bağlıyken mikrofon, kulaklık ve video durumunu değiştirir. `None` olan alan değişmez.       |
| `await bot.voice.leave(guild_id)`                                                   | `None`       | Ses bağlantısını ve LiveKit odasını kapatır. Bağlı değilsen `VOICE_NOT_CONNECTED` fırlatır. |
| `await bot.voice.play_wav(guild_id, path)`                                          | `None`       | Bağlı olduğun ses kanalında bir WAV dosyasını çalar (16-bit PCM). `livekit` paketi gerekir. |
| `await bot.voice.disconnect_all()`                                                  | `None`       | Açık tüm LiveKit odalarını kapatır. `bot.close()` bunu otomatik çağırır.                    |

`leave`, `update` ve `play_wav`, `join` sırasında saklanan bağlantı bilgisini kullanır. Sunucu ses durumu göndermese bile çalışır.

## Ses kanalında kalma

Kütüphane bağlantıyı açık tutmaz. Bot kapanırsa ya da LiveKit koparsa kendiliğinden yeniden girmez. Kalıcı kalmasını istiyorsan `ready` olayında `join` çağır ve bağlantı kopmasını izle. Örnek için `examples/bot_hepsi.py` dosyasına bak.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://micup.renbow.dev/ses.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
