需要两个 Bash/Applescript 来读取和操作文件夹内的文本文件
我有几十个文本 (.txt) 文件,其中包含一长串单词(每行一个),我想使用 OS X Lion“文本转语音”将其转换为音频文件。为此,我需要添加合成语音标记标签来控制语音计时。
脚本 1
以下是 .txt 文件的格式:
Word1
Word2
Word3
以下是创建音频文件所需的内容:
Word1
[[slnc 600]]
[[slnc 900]]
Word1
[[slnc 3000]]
Word2
[[slnc 600]]
[[slnc 900]]
Word2
[[slnc 3000]]
Word3
[[slnc 600]]
[[slnc 900]]
Word3
[[slnc 3000]]
...etc,
文本文件位于我的桌面上名为“Words”的文件夹中。如果可能的话,如果脚本可以指向此文件夹并被告知迭代其中的每个 .txt 文件,执行上述更改,那就太好了。
脚本 2
该脚本需要从名为“French”的桌面文件夹中的 .txt 文件中读取制表符分隔的单词/短语。以下是制表符分隔的 .txt 文件格式:
FrenchWord/Phrase1 EnglishWord/Phrase1
FrenchWord/Phrase2 EnglishWord/Phrase2
...etc,
然后输出为:
say "FrenchWord/Phrase1" using "Thomas"
delay 3
say "EnglishWord/Phrase1" using "Daniel"
delay 5
say "FrenchWord/Phrase2" using "Thomas"
delay 3
say "EnglishWord/Phrase2" using "Daniel"
delay 5
...etc,
由于本例中的 .txt 输入文件包含单个单词和短语,我猜测脚本需要获取“制表符左侧”的所有内容-delimiter' 为法语,所有 'right-of-tab-delimiter' 为 'English'。
任何帮助将不胜感激!:)
干杯,
戴夫
I have a couple dozen text (.txt) files containing long lists of words (one per line) that I want to convert into an audio file using OS X Lion 'Text to Speech.' To do so, I need to add in synth voice markup tags to control speech timing.
Script 1
Here is the format of what I have in .txt files:
Word1
Word2
Word3
Here is what I need to create the audio file:
Word1
[[slnc 600]]
[[slnc 900]]
Word1
[[slnc 3000]]
Word2
[[slnc 600]]
[[slnc 900]]
Word2
[[slnc 3000]]
Word3
[[slnc 600]]
[[slnc 900]]
Word3
[[slnc 3000]]
...etc,
The text files are on my Desktop in a folder called 'Words.' If possible, it would be great if the script could be pointed towards this folder and told to iterate through each .txt file within, performing the changes described above.
Script 2
This one needs to read in tab-delimited words/phrases from .txt files within a Desktop folder called 'French.' Here is the tab-delimited .txt file format:
FrenchWord/Phrase1 EnglishWord/Phrase1
FrenchWord/Phrase2 EnglishWord/Phrase2
...etc,
And then output as:
say "FrenchWord/Phrase1" using "Thomas"
delay 3
say "EnglishWord/Phrase1" using "Daniel"
delay 5
say "FrenchWord/Phrase2" using "Thomas"
delay 3
say "EnglishWord/Phrase2" using "Daniel"
delay 5
...etc,
Since the .txt input files in this case contain both single words and phrases, I'm guessing that the script will need to grab everything 'left-of-tab-delimiter' as French, and everything 'right-of-tab-delimiter' as 'English.'
Any assistance would be immensely appreciated!:)
Cheers,
Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Script1:
Script2:
要批量运行这些,我建议使用
find
和xargs
:Script1:
Script2:
To run these in batch I suggest using
find
andxargs
: