diff --git a/voice_recognition.py b/voice_recognition.py index fcae128..3907912 100644 --- a/voice_recognition.py +++ b/voice_recognition.py @@ -46,8 +46,15 @@ class SRAudioSinkHammerVersion(AudioSink): class Transcriber(commands.Cog): def __init__(self, bot): + def callback(user, data: voice_recv.VoiceData): + logger.info(f"Got packet from {user}") + self.bot = bot self._last_member = None + bsink = voice_recv.BasicSink(callback) + wsink = voice_recv.WaveSink(destination="/home/pi/Conjurer/wav.wav") + fsink = voice_recv.FFmpegSink(filename = ".home/pi/Conjurer/mp3.mp3") + self.sink_list = [bsink, wsink, fsink] async def transcribe(): config = aai.TranscriptionConfig(speaker_labels=True) @@ -61,22 +68,11 @@ class Transcriber(commands.Cog): print(f"Speaker {utterance.speaker}: {utterance.text}") @commands.hybrid_command(name="transcribe") async def test(self, ctx): - def callback(user, data: voice_recv.VoiceData): - logger.info(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 logger.info("Attempt transcribe") vc = await ctx.author.voice.channel.connect(cls=voice_recv.VoiceRecvClient) logger.info("Connected") - wsink = voice_recv.WaveSink(destination="/home/pi/Conjurer/Test.mp3") - fsink = voice_recv.FFmpegSink(filename="/home/pi/Conjurer/Test.mp3") - - vc.listen(fsink) + msink = voice_recv.MultiAudioSink(destinations= self.sink_list) + vc.listen(msink) @commands.command(name="stop_transcribe")