You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: Support voice rcv
* style: linter pass
* fix: further fixes to voice rcv (see desc.)
- Handle rtp header ext without discarding
- ffmpeg now respects decoder settings
- fix errant decode_float opus def
- add `get_ssrc` method to recorder
- sockets are no longer blocking
- irregular sounds (voice) will no longer crash the opus decoder
* ci: correct from checks.
* feat: add ctx.voice_state
* feat 💥: support recording to file
breaking as `start``stop`recording are now async
* fix: prevent re-use of recorders
new recorders are now created as needed
* ci: correct from checks.
* style: linter pass
* fix: ensure recorder can exit when no audio recieved
* feat: add elapsed time to recorder
* ci: correct from checks.
* fix: ensure socket buffer is purged before recording
* feat: send udp keepalive packets
* feat: switch to monotick clock instead of using the audio timestamp
* ci: correct from checks.
* docs: add voice recorder docs
* fix: ensure non-ffmpeg encoders output to file when expected
* refactor: update to comply with linter
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Check out [Active Voice State](/interactions.py/API Reference/API Reference/models/Internal/active_voice_state/) for a list of available methods and attributes.
57
57
58
-
## Okay, but what about Soundcloud?
58
+
#Voice Recording
59
59
60
-
interactions.py has an extension library called [`NAFFAudio`](https://github.com/NAFTeam/NAFF-Audio) which can help with that.
61
-
It has an object called `YTAudio` which can be used to play audio from Soundcloud and other video platforms.
60
+
So you've got a bot that can play music, but what about recording? Well, you're in luck! We've got you covered.
62
61
63
-
```
64
-
pip install naff_audio
65
-
```
62
+
Let's start with a simple example:
66
63
67
64
```python
68
-
from naff_audio import YTAudio
65
+
import asyncio
66
+
import interactions
67
+
68
+
@interactions.slash_command("record", "record some audio")
await ctx.send(files=[interactions.File(file, file_name="user_id.mp3") for user_id, filein voice_state.recorder.output.items()])
77
+
```
78
+
This code will connect to the author's voice channel, start recording, wait 10 seconds, stop recording, and send a file for each user that was recorded.
But what if you didn't want to use `mp3` files? Well, you can change that too! Just pass the encoding you want to use to `start_recording`.
81
+
82
+
```python
83
+
await voice_state.start_recording(encoding="wav")
72
84
```
73
85
74
-
`NAFFAudio` also contains other useful features for audio-bots. Check it out if that's your *jam*.
86
+
For a list of available encodings, check out Recorder's [documentation](/interactions.py/API Reference/API_Communication/voice/recorder.md)
87
+
88
+
Are you going to be recording for a long time? You are going to want to write the files to disk instead of keeping them in memory. You can do that too!
This will write the files to the folder `folder_name` in the current working directory, please note that the library will not create the folder for you, nor will it delete the files when you're done.
0 commit comments