194 lines
3.3 KiB
Markdown
194 lines
3.3 KiB
Markdown
# fastwhisper
|
|
A wraps for [fast-whisper](https://github.com/SYSTRAN/faster-whisper) with following features:
|
|
|
|
* a web server
|
|
* with following API
|
|
|
|
1 transcribe
|
|
|
|
sumits a asr task, and return a dict contains 'task_id' which can use to query task status
|
|
|
|
2 status
|
|
|
|
inquery a task status, if 'SUCCEEDED', the result of transcribe will carry out
|
|
|
|
3 asr
|
|
|
|
sumbit a asr task and wait it success or failed
|
|
|
|
## APIs
|
|
|
|
### transcribe
|
|
|
|
* PATH: /v1/transcribe
|
|
|
|
* headers we need the following header
|
|
```
|
|
{
|
|
"Content-Type": "application/json"
|
|
}
|
|
```
|
|
* data
|
|
```
|
|
{
|
|
"audio_file": a.wav or b.mp3
|
|
}
|
|
```
|
|
|
|
* response
|
|
```
|
|
{
|
|
"task_id": "13hewndskj83r3"
|
|
}
|
|
```
|
|
|
|
* curl examples
|
|
```
|
|
curl -X POST http://127.0.0.1:9925/v1/transcribe \
|
|
-H "Content-TYpe: application/json" \
|
|
-d '{
|
|
"audio_file": "1.wav"
|
|
}'
|
|
```
|
|
|
|
### status
|
|
* path: /v1/status
|
|
|
|
* params
|
|
```
|
|
{
|
|
"task_id": "task id return from transcribe api"
|
|
}
|
|
```
|
|
|
|
* response
|
|
```
|
|
{
|
|
"finished_at": "1762402570.5322073",
|
|
"task_id": "23z2tWN6Z7hlqCgvusigZ",
|
|
"status": "SUCCEEDED",
|
|
"payload": "{\"audio_file\": \"1.wav\"}",
|
|
"started_at": "1762402566.946902",
|
|
"result": {
|
|
"language": "zh",
|
|
"language_probability": 0.99755859375,
|
|
"segments": [
|
|
[
|
|
0.0,
|
|
29.98,
|
|
"优优独播剧场——YoYo Television Series Exclusive"
|
|
],
|
|
[
|
|
123.78,
|
|
126.66000000000001,
|
|
"产品和研发"
|
|
],
|
|
......
|
|
[
|
|
126.66000000000001,
|
|
128.22,
|
|
"哦"
|
|
],
|
|
[
|
|
128.22,
|
|
130.85999999999999,
|
|
"一起把未来憧憬"
|
|
],
|
|
]
|
|
},
|
|
"created_at": "1762402566.9158587"
|
|
}
|
|
```
|
|
#### response explanation
|
|
|
|
* status
|
|
|
|
prosible values are "PENGING":means not starting running, "RUNNING": is running, "FAILED": finished with error, "SUCCEEDED": finished without error
|
|
|
|
* result
|
|
|
|
1 'FAILED'
|
|
|
|
result is the error string
|
|
|
|
2 'SUCCEEDED'
|
|
|
|
result is the transcribe result dict
|
|
keys in result:
|
|
|
|
I language
|
|
|
|
identified language
|
|
|
|
II language_probability
|
|
|
|
probability of language
|
|
|
|
III segments
|
|
it is a list of segment
|
|
|
|
IV segment
|
|
start end text
|
|
|
|
* curl example
|
|
```
|
|
url http://127.0.0.1:9925/v1/status?task_id=23z2tWN6Z7hlqCgvusigZ
|
|
```
|
|
|
|
### asr
|
|
|
|
* path: /v1/asr
|
|
|
|
* headers
|
|
we need the following header
|
|
```
|
|
{
|
|
"Content-Type": "application/json"
|
|
}
|
|
```
|
|
* data
|
|
```
|
|
{
|
|
"audio_file": a.wav or b.mp3
|
|
}
|
|
```
|
|
* response
|
|
```
|
|
{
|
|
"finished_at": "1762402570.5322073",
|
|
"task_id": "23z2tWN6Z7hlqCgvusigZ",
|
|
"status": "SUCCEEDED",
|
|
"payload": "{\"audio_file\": \"1.wav\"}",
|
|
"started_at": "1762402566.946902",
|
|
"result": {
|
|
"language": "zh",
|
|
"language_probability": 0.99755859375,
|
|
"segments": [
|
|
[
|
|
0.0,
|
|
29.98,
|
|
"优优独播剧场——YoYo Television Series Exclusive"
|
|
],
|
|
[
|
|
123.78,
|
|
126.66000000000001,
|
|
"产品和研发"
|
|
],
|
|
......
|
|
[
|
|
126.66000000000001,
|
|
128.22,
|
|
"哦"
|
|
],
|
|
[
|
|
128.22,
|
|
130.85999999999999,
|
|
"一起把未来憧憬"
|
|
],
|
|
]
|
|
},
|
|
"created_at": "1762402566.9158587"
|
|
}
|
|
```
|
|
|