hello
- User
hello
- Assistant
!
Hello! How may I be of assistance?
- User
Traceback (most recent call last): File "C:\meu\expaudiov1.py", line 30, in transcription = model.transcribe(audio) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\vania\AppData\Roaming\Python\Python311\site-packages\whisper\transcribe.py", line 121, in transcribe mel = log_mel_spectrogram(audio, padding=N_SAMPLES) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\vania\AppData\Roaming\Python\Python311\site-packages\whisper\audio.py", line 136, in log_mel_spectrogram audio = F.pad(audio, (0, padding)) ^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: [enforce fail at ..\c10\core\impl\alloc_cpu.cpp:72] data. DefaultCPUAllocator: not enough memory: you tried to allocate 276480576000 bytes.
- Assistant
The error message suggests that there is not enough memory to allocate for your program. The line causing the error is
audio = F.pad(audio, (0, padding)).You may need to consider using a different approach or reducing the size of the input data to avoid the memory error. It may also be helpful to check if you have sufficient memory on your device or allocate more memory for your program to run properly.
- User
import sounddevice as sd import whisper import numpy as np
Load the model
model = 'c:\meu\small.pt' model = whisper.load_model(model)
Capture audio from the microphone
duration = 3 # seconds fs = 16000 # Hz print("Introduza a voz durante 3 segundos") audio1 = sd.rec(int(duration * fs), samplerate=fs, channels=1) sd.wait()
duration = 2.5 # seconds print("Introduza a voz durante 2.5 segundos") audio2 = sd.rec(int(duration * fs), samplerate=fs, channels=1) sd.wait()
duration = 3.5 # seconds print("Introduza a voz durante 3.5 segundos") audio3 = sd.rec(int(duration * fs), samplerate=fs, channels=1) sd.wait()
o erro neste script:
Concatenate the captured audio
audio = np.concatenate((audio2, audio1, audio3))
Transcribe the captured audio
transcription = model.transcribe(audio)
Transcribe each part of the captured audio separately
transcription1 = model.transcribe(audio1) transcription2 = model.transcribe(audio2) transcription3 = model.transcribe(audio3)
Print the transcriptions
print("Transcrição do áudio junto:", transcription) print("Transcrição do áudio 1:", transcription1) print("Transcrição do áudio 2:", transcription2) print("Transcrição do áudio 3:", transcription3)
- Assistant
Could you please provide more details about the error message you are encountering in this script? It would be helpful to know the specific error message and which line of code it is occurring on.
- User
Traceback (most recent call last): File "C:\meu\expaudiov1.py", line 30, in transcription = model.transcribe(audio) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\vania\AppData\Roaming\Python\Python311\site-packages\whisper\transcribe.py", line 121, in transcribe mel = log_mel_spectrogram(audio, padding=N_SAMPLES) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\vania\AppData\Roaming\Python\Python311\site-packages\whisper\audio.py", line 136, in log_mel_spectrogram audio = F.pad(audio, (0, padding)) ^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: [enforce fail at ..\c10\core\impl\alloc_cpu.cpp:72] data. DefaultCPUAllocator: not enough memory: you tried to allocate 276480576000 bytes.
- Assistant
This error message indicates a memory error caused by the
model.transcribe(audio)line. It appears that the program is trying to allocate more memory than is available, causing a memory overflow.You could try reducing the sample size of the audio input or using a lower resolution audio format to decrease the memory required to execute the program. Alternatively, you could try adding a flag to utilize your device's graphics processing unit (GPU) instead of the CPU for model inference, which could significantly reduce the memory required for the program to run.
- User
how adding a flag to utilize your device’s graphics processing unit (GPU)
- Assistant
To add a flag to utilize your device's GPU instead of the CPU, you can modify the call to
load_model()by adding thedeviceparameter like so:codemodel = whisper.load_model('c:\\meu\\small.pt', device="cuda")The
deviceparameter specifies which device to use for model inference. In this case,"cuda"indicates that the GPU should be utilized. If you do not have a GPU, this parameter value will not work. If you don't know which device to use, you can try"cpu"instead.Note that if you are using a GPU, you must have the necessary drivers and libraries installed on your device for PyTorch to utilize the GPU. If you run into any issues, make sure your GPU is properly set up and that PyTorch is configured to use it.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.