I am using Javascript. I have little experience with JavaScript and this is my first time trying to write a script. The Chinese text is not properly read in using this method. For example "他是一位非常著名的演员" gets saved as "‰ªñÊò؉∏ĉΩçÈùûÂ∏∏ËëóÂêçÁöÑʺîÂëò.aiff". I also know the pronunciation is not correct using this method. I've read this documentation and have searched around but can't find anything about this issue. I also have no idea how to write an mp3 file.
var app = Application.currentApplication();
app.includeStandardAdditions = true;
var basePath = "path to directory";
var inputPath = basePath + "/input.txt";
var text = app.read(inputPath).split("\n");
for (let i = 0; i < text.length; i++) {
var recordingPath = basePath + "/" + text[i] + ".aiff";
app.say(text[i], {savingTo: recordingPath});
app.say(text[i]);
}
1条答案
按热度按时间l3zydbqr1#
这看起来像是编码问题。脚本不知道它要读什么,所以你必须告诉它它被编码为
«class utf8»
。我不使用javascript,所以我不能帮助你了解它的语法,但在applescript中,它看起来像这样。音频是独立的,但即使你不知道如何录制到mp3,你也有一些转换选项。itunes可以将AIFF转换为mp3。我不确定shell命令
afconvert
是否可以转换为mp3(看起来不太有希望),但它可以转换为m4a。