Closed on3dd closed 2 years ago
Within the example what command are running to generate audio?
If I understood you correctly:
Handling message event:
def handle_event({:MESSAGE_CREATE, msg, _ws_state}) do
MessageCreate.handle(msg)
end
Processing song request:
"!play song" ->
if Voice.ready?(msg.guild_id) do
Voice.play(msg.guild_id, @soundcloud_url, :ytdl)
else
do_not_ready_msg(msg)
end
I suspect it may be a networking issue with youtube-dl
.
Replace @soundcloud_url
with a path to a local audio file you have on your computer and replace with :ytdl
with :url
Sorry for late response, I tried your suggestion, but it didn't solve the problem. With the following code:
defmodule Berezovskiy.Consumer.MessageCreate do
...
@local_mp3_url "~/code/berezovskiy/Kalimba.mp3"
...
def handle(msg) do
...
"!play song" ->
if Voice.ready?(msg.guild_id) do
Voice.play(msg.guild_id, @local_mp3_url, :url)
else
do_not_ready_msg(msg)
end
...
end
end
I still get the following logs:
20:21:50.510 [debug] VOICE SPEAKING UPDATE %Nostrum.Struct.Event.SpeakingUpdate{channel_id: 580931507712032792, guild_id: 580931507288539177, speaking: true}
20:21:50.718 [debug] VOICE SPEAKING UPDATE %Nostrum.Struct.Event.SpeakingUpdate{channel_id: 580931507712032792, guild_id: 580931507288539177, speaking: false}
and the bot still doesn't speak 😞
It looks like you’re using the latest nostrum release from hex. Try using the master branch from git; the pending 0.5 release has a ton of fixes/new features for voice. Additionally, once you’ve switched, you may also try passing the options realtime: false
as the 4th argument to the play/4
function.
Tried to change release to master branch from git, also tried to set realtime: false
, but both of them gave me the same results: they only added new field to voice logs.
Logs now:
20:10:35.367 [debug] VOICE SPEAKING UPDATE %Nostrum.Struct.Event.SpeakingUpdate{channel_id: 580931507712032792, guild_id: 580931507288539177, speaking: true, timed_out: false}
20:10:35.570 [debug] VOICE SPEAKING UPDATE %Nostrum.Struct.Event.SpeakingUpdate{channel_id: 580931507712032792, guild_id: 580931507288539177, speaking: false, timed_out: true}
Something doesn't seem right that the time between those logs is 200ms. Please completely nuke your dependencies and re-pull all of them and recompile them. Additionally, make sure your ffmpeg
is binary is up to date.
Can confirm, I had the same or rather a similar issue but using the master branch and realtime: false fixed it for me.
I had this issued too After play music from youtube it sound about 2sec then speaking turn to false
I'm closing this for now pending response, feel free to re-open if you're still encountering the issue with realtime: false
on the most recent Nostrum version 0.5.0-rc2
.
I'd like to re-open this issue because I'm having the same issue. I make my bot join my voice channel with /summon
, and then I use /play song
to play the soundcloud url, but it prints in chat that it has to be in a voice channel before being able to play audio. This happens with both the normal Voice.play
and when I've added realtime: false
as an option:
[%{name: "song"}] -> Voice.play(guild_id, @soundcloud_url, :ytdl, realtime: false)
This will occur when your bot joins a voice channel without guild_voice_states
gateway intents enabled.
https://kraigie.github.io/nostrum/gateway_intents.html
Well, I'm not sure what is going on, but it's not working for me. Can you confirm that the following code should work? audio_player_bot.zip
In this project I run iex -S mix
, AudioPlayerSupervisor.start_link([])
, and AudioPlayerConsumer.create_guild_commands(12345) # guild id here
. Then I have the bot join with /summon
and I test it with /play song
, after which it says in chat that it needs to be in a voice channel.
I noticed that I'm getting the following errors in the terminal. I'm assuming it's related.
Could you please try using master? I recall that the hex release may have broken some things related to channel caching.
Ok, it's working now! Thanks for your time
Trying to reproduce the example with voice channels from the documentation, but after starting the audio playback, the bot immediately stops speaking.
Logs:
Source code: https://github.com/on3dd/berezovskiy
What could be the problem? Thank you in advance.