This commit is contained in:
2024-09-17 17:19:00 +02:00
parent 944bb7e5fa
commit 781b83c9b1
+9 -13
View File
@@ -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")