Closed haesleinhuepf closed 2 months ago
This message was generated by git-bob (version: 0.2.3, model: gpt-4o-2024-08-06), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.
It looks like the Listener
class in utilities.py
is missing the get_transcribed_text
method. Please ensure that Listener
includes a method named get_transcribed_text
that returns the expected transcribed text.
How could that function look like? git-bob comment
This message was generated by git-bob (version: 0.2.3, model: gpt-4o-2024-08-06), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.
To resolve the issue, you can add a get_transcribed_text
method within the Listener
class that returns the transcribed text. Here's an example of how you might implement it:
class Listener:
# existing methods
def get_transcribed_text(self, audio_path):
"""Gets the transcribed text from the audio file."""
model = WhisperModel("small", device="cpu")
segments, _ = model.transcribe(audio_path, language="de", word_timestamps=True)
transcription = " ".join([segment.text for segment in segments])
return transcription
Make sure to use your get_transcribed_text
method where necessary in your code to retrieve the transcription.
Instead of creating a new WhisperModel, could we reuse the instance that exists already in the class?
git-bob comment
This message was generated by git-bob (version: 0.2.3, model: gpt-4o-2024-08-06), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.
To reuse the existing WhisperModel
instance, you can initialize it once in the Listener
class's __init__
method and use it in the get_transcribed_text
method. Here's how you can modify the code:
class Listener:
def __init__(self):
self.audio_queue = queue.Queue()
self.sample_rate = 16000
self.audio_data = []
self.stream = sd.InputStream(callback=self.audio_callback, samplerate=self.sample_rate, channels=1, dtype='int16')
self.model = WhisperModel("small", device="cpu") # Initialize the model here
# existing methods
def get_transcribed_text(self, audio_path):
"""Gets the transcribed text from the audio file."""
segments, _ = self.model.transcribe(audio_path, language="de", word_timestamps=True)
transcription = " ".join([segment.text for segment in segments])
return transcription
With these changes, the existing WhisperModel
instance is reused for transcription. Update other methods as needed to use get_transcribed_text
if required.
git-bob implement this!
When executing "python main.py" I receive this error:
git-bob comment