bugfix
This commit is contained in:
parent
ee1f718152
commit
fed4c53ba6
@ -67,6 +67,9 @@ bash ./build.sh
|
|||||||
```
|
```
|
||||||
{
|
{
|
||||||
"audio_file": a.wav or b.mp3
|
"audio_file": a.wav or b.mp3
|
||||||
|
"beam_size": default is 5
|
||||||
|
"temperature": default is 0.0
|
||||||
|
"word_timestamps": default is True
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
42
fw/fw.py
42
fw/fw.py
@ -37,20 +37,36 @@ class MyLongTask(LongTasks):
|
|||||||
fs = FileStorage()
|
fs = FileStorage()
|
||||||
fpath = fs.realPath(webpath)
|
fpath = fs.realPath(webpath)
|
||||||
f = awaitify(self.transcribe)
|
f = awaitify(self.transcribe)
|
||||||
return await f(model, fpath)
|
options = {
|
||||||
|
'beam_size': payload.get('beam_size', 5),
|
||||||
|
'temperature': payload.get('temperature', 0.0),
|
||||||
|
'word_timestamps': payload.get('word_timestamps', True)
|
||||||
|
}
|
||||||
|
return await f(model, fpath, options)
|
||||||
|
|
||||||
def transcribe(self, model, fpath):
|
def transcribe(self, model, fpath, options):
|
||||||
segments, info = model.transcribe(fpath, beam_size=5, word_timestamps=True)
|
segments, info = model.transcribe(fpath, **options)
|
||||||
segments = list(segments)
|
segments = list(segments)
|
||||||
debug(f'{segments=}')
|
debug(f'{segments=}')
|
||||||
return {
|
if 'word_timestamps' in options.keys():
|
||||||
'language': info.language,
|
return {
|
||||||
'language_probability': info.language_probability,
|
'language': info.language,
|
||||||
'content': ' '.join([s.text for s in segments]),
|
'language_probability': info.language_probability,
|
||||||
'segments': [[s.start,
|
'content': ' '.join([s.text for s in segments]),
|
||||||
s.end,
|
'segments': [[s.start,
|
||||||
s.text,
|
s.end,
|
||||||
[[w.start, w.end, w.word] for w in s.words]
|
s.text,
|
||||||
] for s in segments]
|
[[w.start, w.end, w.word] for w in s.words]
|
||||||
}
|
] for s in segments]
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
'language': info.language,
|
||||||
|
'language_probability': info.language_probability,
|
||||||
|
'content': ' '.join([s.text for s in segments]),
|
||||||
|
'segments': [[s.start,
|
||||||
|
s.end,
|
||||||
|
s.text,
|
||||||
|
] for s in segments]
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user