Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update voice recording example #1605

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from

Conversation

jasondilworth56
Copy link

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

The existing example does not work due to missing deferral and missing message body, this fixes both.

Changes

  • Added a called to ctx.defer() at beginning of example
  • Added message body to output from example

Related Issues

Test Scenarios

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

The existing example does not work due to missing deferral and missing message body, this fixes both.

Signed-off-by: Jason Dilworth <hello@jasondilworth.co.uk>
voice_state = await ctx.author.voice.channel.connect()

# Start recording
await voice_state.start_recording()
await asyncio.sleep(10)
await voice_state.stop_recording()
await ctx.send(files=[interactions.File(file, file_name="user_id.mp3") for user_id, file in voice_state.recorder.output.items()])
await ctx.send("Here are your recordings", files=[interactions.File(file, file_name="user_id.mp3") for user_id, file in voice_state.recorder.output.items()])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content here shouldn't be needed. What error are you getting here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot test again until a bit later, but there was an error about the message not being empty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because you didn't actually send/capture any audio. You need to talk and should visually see that your microphone is activating. Without any text or file attachments, the message was empty, hence the error.

files=[interactions.File(file, file_name=f"{user_id}.mp3") for user_id, file in voice_state.recorder.output.items()]
if len(files) > 0:
    await ctx.send(files=files)
else:
    await ctx.send("No audio was recorded.")

docs/src/Guides/23 Voice.md Show resolved Hide resolved
@eightween
Copy link
Member

Putting on hold until requests are met and satisfied

@eightween eightween added documentation Improvements or additions to documentation on hold This issue/PR is on hold pending higher priority issues/PRs labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation on hold This issue/PR is on hold pending higher priority issues/PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants