-
Notifications
You must be signed in to change notification settings - Fork 285
/
Copy pathoffline_inference.py
40 lines (33 loc) · 1.09 KB
/
offline_inference.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import torchaudio
import argparse
from stepaudio import StepAudio
def main():
parser = argparse.ArgumentParser(description="StepAudio Offline Inference")
parser.add_argument(
"--model-path", type=str, required=True, help="Base path for model files"
)
args = parser.parse_args()
model = StepAudio(
tokenizer_path=f"{args.model_path}/Step-Audio-Tokenizer",
tts_path=f"{args.model_path}/Step-Audio-TTS-3B",
llm_path=f"{args.model_path}/Step-Audio-Chat",
)
# example for text input
text, audio, sr = model(
[{"role": "user", "content": "你好,我是你的朋友,我叫小明,你叫什么名字?"}],
"Tingting",
)
torchaudio.save("output/output_e2e_tqta.wav", audio, sr)
# example for audio input
text, audio, sr = model(
[
{
"role": "user",
"content": {"type": "audio", "audio": "output/output_e2e_tqta.wav"},
}
],
"Tingting",
)
torchaudio.save("output/output_e2e_aqta.wav", audio, sr)
if __name__ == "__main__":
main()