Skip to content

Commit

Permalink
set.ini add params
Browse files Browse the repository at this point in the history
  • Loading branch information
jianchang512 committed Jan 28, 2024
1 parent 815cdf1 commit 51f9ca5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
11 changes: 10 additions & 1 deletion set.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ lang=
; cpu or cuda
devtype=cpu
; int8 or float32 only gpu
cuda_com_type=int8
cuda_com_type=int8
;Reducing these two numbers will use less graphics memory
beam_size=1
best_of=1
;vad set to false,use litter GPU memory,true is more
vad=true
;0 is use litter GPU,other is more
temperature=0
;false is litter GPU,ture is more
condition_on_previous_text=false
4 changes: 2 additions & 2 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def shibie(*, wav_name=None, model=None, language=None, data_type=None, wav_file
sets=cfg.parse_ini()
modelobj = WhisperModel(model, device=sets.get('devtype'), compute_type=sets.get('cuda_com_type'), download_root=cfg.ROOT_DIR + "/models", local_files_only=True)
cfg.progressbar=0
segments,info = modelobj.transcribe(wav_file, beam_size=1,best_of=1,temperature=0, vad_filter=True, vad_parameters=dict(min_silence_duration_ms=500),language=language)
segments,info = modelobj.transcribe(wav_file, beam_size=sets.get('beam_size'),best_of=sets.get('best_of'),temperature=0 if sets.get('temperature')==0 else [0.0,0.2,0.4,0.6,0.8,1.0],condition_on_previous_text=sets.get('condition_on_previous_text'),vad_filter=sets.get('vad'), vad_parameters=dict(min_silence_duration_ms=500),language=language)
total_duration = round(info.duration, 2) # Same precision as the Whisper timestamps.

raw_subtitles = []
Expand Down Expand Up @@ -223,7 +223,7 @@ def api():
sets=cfg.parse_ini()
model = WhisperModel(model, device=sets.get('devtype'), compute_type=sets.get('cuda_com_type'), download_root=cfg.ROOT_DIR + "/models", local_files_only=True)

segments,_ = model.transcribe(wav_file, beam_size=1,best_of=1,temperature=0, vad_filter=True,
segments,_ = model.transcribe(wav_file, beam_size=sets.get('beam_size'),best_of=sets.get('best_of'),temperature=0 if sets.get('temperature')==0 else [0.0,0.2,0.4,0.6,0.8,1.0],condition_on_previous_text=sets.get('condition_on_previous_text'),vad_filter=sets.get('vad'),
vad_parameters=dict(min_silence_duration_ms=500),language=language)
raw_subtitles = []
for segment in segments:
Expand Down
4 changes: 2 additions & 2 deletions stslib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION=9
version_str="v0.0.9"
VERSION=91
version_str="v0.0.91"
14 changes: 11 additions & 3 deletions stslib/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ def parse_ini(file=os.path.join(ROOT_DIR,'set.ini')):
"web_address":"127.0.0.1:9977",
"lang":"en" if locale.getdefaultlocale()[0].split('_')[0].lower() != 'zh' else "zh",
"devtype":"cpu",
"cuda_com_type":"int8"
"cuda_com_type":"int8",
"beam_size":1,
"best_of":1,
"vad":True,
"temperature":0,
"condition_on_previous_text":False

}
if not os.path.exists(file):
return sets
Expand All @@ -21,8 +27,10 @@ def parse_ini(file=os.path.join(ROOT_DIR,'set.ini')):
line=[ x.strip() for x in line.strip().split('=', maxsplit=1)]
if len(line)!=2:
continue
if line[1]=='false' or line[1]=='true':
sets[line[0]] = True if line[1]=='true' else False
if line[1]=='false':
sets[line[0]] = False
elif line[1]=='true':
sets[line[0]] = True
elif re.match(r'^\d+$', line[1]):
sets[line[0]]=int(line[1])
elif line[1]:
Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version":"v0.0.9",
"version_num":9
"version":"v0.0.91",
"version_num":91
}

0 comments on commit 51f9ca5

Please sign in to comment.