mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-16 23:02:10 +00:00
fx
This commit is contained in:
+27
-8
@@ -27,6 +27,9 @@ discord.opus._load_default()
|
|||||||
# URL of the file to transcribe
|
# URL of the file to transcribe
|
||||||
# You can also transcribe a local file by passing in a file path
|
# You can also transcribe a local file by passing in a file path
|
||||||
# FILE_URL = './path/to/file.mWp3
|
# FILE_URL = './path/to/file.mWp3
|
||||||
|
CHANNELS = OpusDecoder.CHANNELS
|
||||||
|
SAMPLE_WIDTH = OpusDecoder.SAMPLE_SIZE // OpusDecoder.CHANNELS
|
||||||
|
SAMPLING_RATE = OpusDecoder.SAMPLING_RATE
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("discord")
|
logger = logging.getLogger("discord")
|
||||||
@@ -49,7 +52,7 @@ class Events(commands.Cog):
|
|||||||
logger.info("After %s", after)
|
logger.info("After %s", after)
|
||||||
|
|
||||||
|
|
||||||
class UserTranscript:
|
class WaveWriter:
|
||||||
def __init__(self, user_id):
|
def __init__(self, user_id):
|
||||||
|
|
||||||
self.username = str(user_id)
|
self.username = str(user_id)
|
||||||
@@ -60,11 +63,18 @@ class UserTranscript:
|
|||||||
self.transcript_file_present = wave.Wave_write = wave.open(
|
self.transcript_file_present = wave.Wave_write = wave.open(
|
||||||
self.file_name_present, "wb"
|
self.file_name_present, "wb"
|
||||||
)
|
)
|
||||||
|
self.transcript_file_present.setnchannels(CHANNELS)
|
||||||
|
self.transcript_file_present.setsampwidth(SAMPLE_WIDTH)
|
||||||
|
self.transcript_file_present.setframerate(SAMPLING_RATE)
|
||||||
|
|
||||||
self.file_name_future = location + self.username + str(self.present_file_id + 1)
|
self.file_name_future = location + self.username + str(self.present_file_id + 1)
|
||||||
self.transcript_file_future = wave.Wave_write = wave.open(
|
self.transcript_file_future = wave.Wave_write = wave.open(
|
||||||
self.file_name_future, "wb"
|
self.file_name_future, "wb"
|
||||||
)
|
)
|
||||||
|
self.file_name_future.setnchannels(CHANNELS)
|
||||||
|
self.file_name_future.setsampwidth(SAMPLE_WIDTH)
|
||||||
|
self.file_name_future.setframerate(SAMPLING_RATE)
|
||||||
|
|
||||||
|
|
||||||
def rotate(self):
|
def rotate(self):
|
||||||
self.transcript_file_present.close()
|
self.transcript_file_present.close()
|
||||||
@@ -78,7 +88,10 @@ class UserTranscript:
|
|||||||
self.transcript_file_future = wave.Wave_write = wave.open(
|
self.transcript_file_future = wave.Wave_write = wave.open(
|
||||||
self.file_name_future, "wb"
|
self.file_name_future, "wb"
|
||||||
)
|
)
|
||||||
# send past to transcription
|
self.file_name_future.setnchannels(CHANNELS)
|
||||||
|
self.file_name_future.setsampwidth(SAMPLE_WIDTH)
|
||||||
|
self.file_name_future.setframerate(SAMPLING_RATE)
|
||||||
|
# send present to transcription
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
self.transcript_file_present.close()
|
self.transcript_file_present.close()
|
||||||
@@ -91,9 +104,6 @@ class SRBuffer(voice_recv.AudioSink):
|
|||||||
Best used in conjunction with a silence generating sink. (TBD)
|
Best used in conjunction with a silence generating sink. (TBD)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CHANNELS = OpusDecoder.CHANNELS
|
|
||||||
SAMPLE_WIDTH = OpusDecoder.SAMPLE_SIZE // OpusDecoder.CHANNELS
|
|
||||||
SAMPLING_RATE = OpusDecoder.SAMPLING_RATE
|
|
||||||
|
|
||||||
# on member join dodajemytypa do listy
|
# on member join dodajemytypa do listy
|
||||||
# on member disconnect - dropujemy go
|
# on member disconnect - dropujemy go
|
||||||
@@ -102,10 +112,17 @@ class SRBuffer(voice_recv.AudioSink):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self._file: wave.Wave_write = wave.open(destination, "wb")
|
self._file: wave.Wave_write = wave.open(destination, "wb")
|
||||||
self._file.setnchannels(self.CHANNELS)
|
self._file.setnchannels(CHANNELS)
|
||||||
self._file.setsampwidth(self.SAMPLE_WIDTH)
|
self._file.setsampwidth(SAMPLE_WIDTH)
|
||||||
self._file.setframerate(self.SAMPLING_RATE)
|
self._file.setframerate(SAMPLING_RATE)
|
||||||
self.user_list = {}
|
self.user_list = {}
|
||||||
|
self.wavewriter = {}
|
||||||
|
|
||||||
|
def on_user_connect(self, username):
|
||||||
|
self.wavewriter[username] = WaveWriter(username)
|
||||||
|
|
||||||
|
def on_user_disconnect(self,username):
|
||||||
|
self.wavewriter[username].cleanup()
|
||||||
|
|
||||||
def wants_opus(self) -> bool:
|
def wants_opus(self) -> bool:
|
||||||
return False
|
return False
|
||||||
@@ -141,7 +158,9 @@ class Transcriber(commands.Cog):
|
|||||||
@commands.hybrid_command(name="transcribe")
|
@commands.hybrid_command(name="transcribe")
|
||||||
async def test(self, ctx):
|
async def test(self, ctx):
|
||||||
logger.info("Attempt transcribe")
|
logger.info("Attempt transcribe")
|
||||||
|
vc = None
|
||||||
vc = await ctx.author.voice.channel.connect(cls=voice_recv.VoiceRecvClient)
|
vc = await ctx.author.voice.channel.connect(cls=voice_recv.VoiceRecvClient)
|
||||||
|
logger.info(self.bot.voice_clients)
|
||||||
logger.info("Connected")
|
logger.info("Connected")
|
||||||
vc.listen(self.wsink)
|
vc.listen(self.wsink)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user