Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use the variable for input parameter? #40

Closed
bk111 opened this issue Dec 28, 2022 · 1 comment
Closed

How can I use the variable for input parameter? #40

bk111 opened this issue Dec 28, 2022 · 1 comment

Comments

@bk111
Copy link

bk111 commented Dec 28, 2022

print(type(names1["hot50_cn_topic_" + str(i) ][0:280])) #结果为 str

input1 = names1["hot50_cn_topic_" + str(i) ][0:280]
input2 = "近日在全国多地,许多新冠感染者们已陆续转阴,回归到正常的生活和工作中。"

#os.system('aspeak -t names1["hot50_cn_topic_" + str(i) ][0:280] -o "./1/{}{}{}".format(year, month, day)+str(i)+".mp3" -l zh-CN') # 结果: -t names1["hot50_cn_topic" + str(i) ][0:280] 格式不正常
#os.system('aspeak -t input1 -v zh-CN-YunjianNeural -R YoungAdultMale -o "{}".mp3'.format(out1)) # 结果: -t input1 格式不正常
#os.system('aspeak -t input2 -v zh-CN-YunjianNeural -R YoungAdultMale -o "{}".mp3'.format(out1)) # 结果: -t input2 格式不正常

os.system('aspeak -t """近日在全国多地,许多新冠感染者们已陆续转阴,回归到正常的生活和工作中。""" -v zh-CN-YunjianNeural -R YoungAdultMale -o "{}".mp3'.format(out1)) #这个是正常的

-t 之后的输入参数 怎么才能换成变量呢?

@kxxt
Copy link
Owner

kxxt commented Dec 28, 2022

你既然已经在用 Python 了,为什么不直接调 API 呢?😂

文档:https://github.com/kxxt/aspeak/blob/main/DEVELOP.md

如果要用 CLI 的话,也没必要直接拼接命令啊.... 拼接命令要先转义字符串。直接从 stdin 读入多好

from subprocess import run
run(executable='aspeak', args=['-t', '-l', 'zh-CN', '-o', 'result.wav'], input='放你想要的字符串', encoding='utf-8')

@kxxt kxxt closed this as completed Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants