赞
踩
https://www.bilibili.com/video/BV1Z7421K7vL/
【xinference】(3):在autodl上,使用xinference部署whisper-tiny音频模型,并成功将语音转换成文本
https://inference.readthedocs.io/zh-cn/latest/user_guide/model_abilities/audio.html
模型需要执行脚本启动:
pip3 install "xinference[all]"
apt update && apt install -y ffmpeg
# 设置学术加速,不再区分不同地区
# https://www.autodl.com/docs/network_turbo/
source /etc/network_turbo
export XINFERENCE_MODEL_SRC=modelscope
export XINFERENCE_HOME=/root/autodl-tmp
# 首先启动 xinference-local :
xinference-local --host 0.0.0.0 --port 9997
执行命令:
# 大模型
xinference launch --model-uid whisper-1 --model-name whisper-large-v3 --model-type audio
# 小模型
xinference launch --model-uid whisper-1 --model-name whisper-tiny --model-type audio
如果大模型下载异常,可以使用小模型下载。
启动成功,占用显存 3G
nvidia-smi
Wed Jan 31 23:54:27 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.146.02 Driver Version: 535.146.02 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce RTX 3080 On | 00000000:86:00.0 Off | N/A |
| 0% 25C P8 15W / 320W | 3405MiB / 20480MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
+---------------------------------------------------------------------------------------+
from xinference.client import Client
client = Client("http://localhost:9997")
# xinference launch --model-uid whisper-1 --model-name whisper-tiny --model-type audio
# model_uid = client.launch_model(model_uid="whisper-1",model_name="whisper-tiny", model_type="audio")
# whisper-tiny
model = client.get_model("whisper-1")
input_text = "an apple"
with open("voice-test.mp3", "rb") as audio_file:
out = model.transcriptions(audio_file.read())
print(out['text'])
执行结果:
本列表列出香港航空的航点,正确。
音频文件在这里:
https://github.com/xorbitsai/inference/tree/main/xinference/model/audio/tests
确实可以运行音频大模型。可以将音频文件转换成文本。
可以做啥呢?可以直接录用转文字,或者做字幕。
transcriptions 是音频转文本
translations 可以直接将音频翻译成英文。
使用large 模型就可以翻译:
本列表列出香港航空的航点 > 翻译成:
This list lists the airlines in Hong Kong.
还集成了翻译模块。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。