This commit is contained in:
2024-08-23 18:46:40 +02:00
parent e6648926a6
commit 7857226e12
5 changed files with 274 additions and 10 deletions
+25 -1
View File
@@ -6,9 +6,10 @@
import assemblyai as aai
import discord
from discord.ext import commands
from discord.ext import commands, voice_recv
# Replace with your API key
aai.settings.api_key = "aa9962f0088a449a9c4ab2361e96cc08"
discord.opus._load_default()
# URL of the file to transcribe
FILE_URL = "https://github.com/AssemblyAI-Community/audio-examples/raw/main/20230607_me_canadian_wildfires.mp3"
@@ -49,6 +50,29 @@ class Transcriber(commands.Cog):
)
for utterance in transcript.utterances:
print(f"Speaker {utterance.speaker}: {utterance.text}")
@commands.hybrid_command(name="test")
async def test(self, ctx):
def callback(user, data: voice_recv.VoiceData):
print(f"Got packet from {user}")
## voice power level, how loud the user is speaking
# ext_data = packet.extension_data.get(voice_recv.ExtensionID.audio_power)
# value = int.from_bytes(ext_data, 'big')
# power = 127-(value & 127)
# print('#' * int(power * (79/128)))
## instead of 79 you can use shutil.get_terminal_size().columns-1
vc = await ctx.author.voice.channel.connect(cls=voice_recv.VoiceRecvClient)
vc.listen(voice_recv.BasicSink(callback))
@commands.command()
async def stop(self, ctx):
await ctx.voice_client.disconnect()
@commands.command()
async def die(self, ctx):
ctx.voice_client.stop()
await ctx.bot.close()
async def setup(bot):
await bot.add_cog(Transcriber(bot))