mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Fix
This commit is contained in:
+25
-1
@@ -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))
|
||||
Reference in New Issue
Block a user