fix: Use functools.partial for transcribing audio with Whisper model in VoiceGatewayCog
This commit is contained in:
parent
7dd00644a2
commit
1c5db9f9e9
@ -4,6 +4,7 @@ import asyncio
|
||||
import os
|
||||
import tempfile
|
||||
import wave # For saving audio data
|
||||
import functools # Added for partial
|
||||
import subprocess # For audio conversion
|
||||
from discord.ext import voice_recv # For receiving voice
|
||||
|
||||
@ -420,12 +421,11 @@ class VoiceGatewayCog(commands.Cog):
|
||||
wf.close()
|
||||
|
||||
# Transcribe using Whisper (this can be blocking, run in executor)
|
||||
loop = asyncio.get_event_loop()
|
||||
result = await loop.run_in_executor(
|
||||
# Use functools.partial to pass keyword arguments to the transcribe method
|
||||
transcribe_func = functools.partial(self.whisper_model.transcribe, wav_file_path, fp16=False)
|
||||
result = await self.bot.loop.run_in_executor(
|
||||
None, # Default ThreadPoolExecutor
|
||||
self.whisper_model.transcribe,
|
||||
wav_file_path,
|
||||
fp16=False # Set to True if GPU supports it and you want faster inference
|
||||
transcribe_func
|
||||
)
|
||||
transcribed_text = result["text"].strip()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user