{"action":"created","issue":{"url":"https://api.github.com/repos/Rapptz/discord.py/issues/1509","repository_url":"https://api.github.com/repos/Rapptz/discord.py","labels_url":"https://api.github.com/repos/Rapptz/discord.py/issues/1509/labels{/name}","comments_url":"https://api.github.com/repos/Rapptz/discord.py/issues/1509/comments","events_url":"https://api.github.com/repos/Rapptz/discord.py/issues/1509/events","html_url":"https://github.com/Rapptz/discord.py/issues/1509","id":350010769,"node_id":"MDU6SXNzdWUzNTAwMTA3Njk=","number":1509,"title":"play_audio only plays a short hissing sound","user":{"login":"SilasBerger","id":8812237,"node_id":"MDQ6VXNlcjg4MTIyMzc=","avatar_url":"https://avatars3.githubusercontent.com/u/8812237?v=4","gravatar_id":"","url":"https://api.github.com/users/SilasBerger","html_url":"https://github.com/SilasBerger","followers_url":"https://api.github.com/users/SilasBerger/followers","following_url":"https://api.github.com/users/SilasBerger/following{/other_user}","gists_url":"https://api.github.com/users/SilasBerger/gists{/gist_id}","starred_url":"https://api.github.com/users/SilasBerger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilasBerger/subscriptions","organizations_url":"https://api.github.com/users/SilasBerger/orgs","repos_url":"https://api.github.com/users/SilasBerger/repos","events_url":"https://api.github.com/users/SilasBerger/events{/privacy}","received_events_url":"https://api.github.com/users/SilasBerger/received_events","type":"User","site_admin":false},"labels":[{"id":251130946,"node_id":"MDU6TGFiZWwyNTExMzA5NDY=","url":"https://api.github.com/repos/Rapptz/discord.py/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-13T12:34:46Z","updated_at":"2018-08-20T01:40:57Z","closed_at":"2018-08-20T01:40:57Z","author_association":"NONE","body":"## System information [edited]\r\n- Windows 10\r\n- Python 3.6.5rc1, 64-bit\r\n\r\n## Problem description\r\nI'm having troubles with the `play_audio` function in the `discord.py[voice]` library.\r\n\r\nAt the start of the script, I load my demo opus sound file as follows:\r\n```\r\nwith open(\"assets/audio/testAudioFile.opus\", \"rb\") as file:\r\n    demo_audio_file = file.read()\r\n```\r\n\r\nWhen the bot is ready, I check for the opus library; the output is `True`:\r\n```\r\n@bot.event\r\nasync def on_ready():\r\n    [...]\r\n    print(\"opus library loaded:\", discord.opus.is_loaded())\r\n```\r\n\r\nI then have a command that lets the bot user join the message author's voice channel, which invokes the following function:\r\n```\r\nactive_voice_channel = await bot.join_voice_channel(voice_channel)\r\n```\r\n...where the `voice_channel` argument is the message author's `voice_channel` property.\r\n\r\nThe bot successfully joins the correct voice channel. Finally, I have a command that should play the demo audio file by calling the following method:\r\n```\r\nasync def play_sound(channel, args):\r\n    await bot.send_message(channel, \"Playing sound with the following arguments: \" + \", \".join(args))\r\n    active_voice_channel.play_audio(demo_audio_file, encode=True)\r\n```\r\n\r\nThis is where the problem occurs. The function gets called, the message gets sent and a sound gets played. However, instead of playing the audio file, you can only hear a very short hissing sound in the Discord voice channel. The script does not show any errors. Am I doing something wrong?\r\n"},"comment":{"url":"https://api.github.com/repos/Rapptz/discord.py/issues/comments/414174923","html_url":"https://github.com/Rapptz/discord.py/issues/1509#issuecomment-414174923","issue_url":"https://api.github.com/repos/Rapptz/discord.py/issues/1509","id":414174923,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDE3NDkyMw==","user":{"login":"Rapptz","id":1695103,"node_id":"MDQ6VXNlcjE2OTUxMDM=","avatar_url":"https://avatars3.githubusercontent.com/u/1695103?v=4","gravatar_id":"","url":"https://api.github.com/users/Rapptz","html_url":"https://github.com/Rapptz","followers_url":"https://api.github.com/users/Rapptz/followers","following_url":"https://api.github.com/users/Rapptz/following{/other_user}","gists_url":"https://api.github.com/users/Rapptz/gists{/gist_id}","starred_url":"https://api.github.com/users/Rapptz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rapptz/subscriptions","organizations_url":"https://api.github.com/users/Rapptz/orgs","repos_url":"https://api.github.com/users/Rapptz/repos","events_url":"https://api.github.com/users/Rapptz/events{/privacy}","received_events_url":"https://api.github.com/users/Rapptz/received_events","type":"User","site_admin":false},"created_at":"2018-08-20T01:40:57Z","updated_at":"2018-08-20T01:40:57Z","author_association":"OWNER","body":"`play_audio` is a lower-level hook that accepts very specific things, mainly PCM. From your `.opus` extension I can only assume that it's not raw PCM. It's also meant to be called in a loop with specific timing (20ms per frame size).\r\n\r\nBasically, I believe you're using the wrong tool for what you want to do. Generally people just spawn an ffmpeg process to handle this instead of using the admittedly hard to use lower-level `play_audio`."}}
{"actor":{"display_login":"Rapptz"}}