|
a |
|
b/whs.py |
|
|
1 |
import whisper |
|
|
2 |
import configparser |
|
|
3 |
|
|
|
4 |
def get_model_options(): |
|
|
5 |
models = whisper.available_models() |
|
|
6 |
print('Available models: ', ''.join(models)) |
|
|
7 |
|
|
|
8 |
def load_model(): |
|
|
9 |
# Selected and load from the list of available models that can fit in your system |
|
|
10 |
|
|
|
11 |
# Initialize ConfigParser |
|
|
12 |
config = configparser.ConfigParser() |
|
|
13 |
|
|
|
14 |
# Read settings.ini file |
|
|
15 |
config.read('settings.ini') |
|
|
16 |
# Get values |
|
|
17 |
whisper_model = config.get('Local Wisper Settings', 'whisper_model') |
|
|
18 |
|
|
|
19 |
# Load the model |
|
|
20 |
print(f'Loading the {whisper_model} model...') |
|
|
21 |
model = whisper.load_model(whisper_model) |
|
|
22 |
print('Model loaded') |
|
|
23 |
|
|
|
24 |
return model |
|
|
25 |
|
|
|
26 |
def test_whisper(file='audio_chunk.wav'): |
|
|
27 |
model = load_model() |
|
|
28 |
transcription = model.transcribe(file) |
|
|
29 |
print(transcription['text']) |