+
99
-

回答

首先明确需求和操作步骤,应用必须要实时监听获取面试官的提问,然后手动确认问题调用大模型api流式输出,这里面第一个技术是实时获取面试官的语音问题转成文字,这里推荐使用开源的whisper-large-v3-turbo

800_auto

使用/whisper-large-v3-turbo实时获取说话者的文本后再点击确认调用ai大模型的api即可实现

import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
from datasets import load_dataset


device = "cuda:0" if torch.cuda.is_available() else "cpu"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32

model_id = "openai/whisper-large-v3-turbo"

model = AutoModelForSpeechSeq2Seq.from_pretrained(
    model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
)
model.to(device)

processor = AutoProcessor.from_pretrained(model_id)

pipe = pipeline(
    "automatic-speech-recognition",
    model=model,
    tokenizer=processor.tokenizer,
    feature_extractor=processor.feature_extractor,
    torch_dtype=torch_dtype,
    device=device,
)

dataset = load_dataset("distil-whisper/librispeech_long", "clean", split="validation")
sample = dataset[0]["audio"]

result = pipe(sample)
print(result["text"])

https://huggingface.co/openai/whisper-large-v3-turbo

体验地址:https://huggingface.co/spaces/KingNish/Realtime-whisper-large-v3-turbo

网友回复

我知道答案,我要回答