内容
[重要:与Macos Sonoma(14)的部分破裂:许多安装的声音未识别,并且默认语音未使用-l列出]
voices是一种MacOS CLI,用于更改默认的TTS(文本到语音)语音,并用于打印有关带有多个声音的文本的信息。
voices通过say
say包装器,该包装器支持带有嵌入式说明的文本,以更改语音中间文本(例如, [[voice alex]] ),假设您已经安装了PowerShell,请参见此评论。警告:
从MACOS 10.12(Sierra)开始,没有任何有记录的编程方法来更改默认语音。因此,该实用程序利用了无证件的系统内部设备,不幸的是,这意味着此功能的未来兼容性尚不确定。欢迎反馈。
当前的voices只能完全支持Apple提供的声音。支持第三方声音(例如Infovox Ivox)仅限于与他们交谈,下面记录的MACOS服务将无法与之搭配。
此外,从MACOS 10.15开始,由于缺乏API支持,因此不支持Siri声音(请参阅此堆栈溢出问题)。
请参阅下面的示例,简明的用法信息,或阅读手册。
此外,还提供了两种MacOS服务:
注意:如果您拥有Alfred的电源包,请考虑使用WorkFlow Spee.AWF作为优越的选择。
# List all active voices; add -a to list all installed ones.
voices -l
# Print information about the default voice and speak its demo text.
voices -d -k
# Print information about voice 'Alex'.
voices alex
# Make 'Alex' the new default voice, print information about it, and
# speak text that announces the change.
voices -k ' The new default voice is Alex. ' -d alex
# List languages for which at least one voice is active.
voices -L
# List active French voices.
voices -l fr
# Print information about all active voices and speak
# their respective demo text.
voices -l -k
# Print information about all active Spanish voices and speak their
# respective demo text.
voices -k -l es
# Say "hello", first with voice Alex, then with Jill, suppressing printed
# output.
voices -k " hello " -q alex jill支持的平台
经过验证,可以从OS X 10.8(Mountain Lion)到MacOS 10.12(Sierra)工作。
更改默认的声音功能利用了无证件的系统内部设备,因此其未来兼容性尚不确定。如果您发现未来的MacOS版本中损坏的功能,请告诉我。
注意:即使您不使用node.js,它的软件包管理器npm ,也可以跨平台工作,并且易于安装;尝试curl -L http://git.io/n-install | bash
安装了node.js,按照以下方式安装软件包:
[sudo] npm install voices -g
笔记:
sudo取决于您如何安装node.js / io.js以及以后是否更改了权限;如果您遇到EACCES错误,请与sudo重试。-g确保全局安装,并且需要将voices放入系统的$PATH中。 voices 。chmod +x voices使其可执行。$PATH中的文件夹,例如/usr/local/bin 。在下面找到简明的用法信息;有关完整的文档,请在线阅读手册,或者,一旦安装,请运行man voices ( voices --man如果手动安装)。
$ voices --help
Get or set or speak with the DEFAULT VOICE:
voices [<options>] [-d [<newDefaultVoice>]]
LIST INFORMATION about / speak with voices:
voices [<options>] <voice>...
List / speak with ALL VOICES, optionally FILTERED BY LANGUAGES:
voices [<options>] -l [<lang>...]
LIST LANGUAGES among voices:
voices -L [-a]
MANAGE VOICES in System Preferences:
voices -m
Shared options (synopsis forms 1-3):
-a target all installed voices (default: only active ones)
-k speak demo text with all targeted voices
-k"<text>" speak specified text
-k- speak text provided via stdin
-b output format: print voice names only
-i output format: print voice internals
-q quiet mode: no printed output
Standard options: --help, --man, --version, --home
如果您使用两种或多种语言的文本到语音,并且希望快速在多个指定的声音之间循环地将默认的语音转换,则使用嵌入式voices副本,它将与内置的Speak-Seal-Selected-Text Service相结合,将很有帮助。
每次调用该服务时,将使下一个指定的语音成为默认语音,并说出新语音语言的本地名称以确认更改(这是可配置的)。
您可以从任何应用程序的标准Services菜单,类别General调用服务,或通过System Preferences > Keyboard > Shortcuts > Services分配键盘快捷键。
Switch Default Voice.workflow 。Switch Default Voice.workflow并在提示时选择Install - 将软件包放入~/Library/Services/ 。Done ,并在下面进行自定义。 Services > Switch Default Voice 。System Preferences > Keyboard > Shortcuts ,类别Services ,滚动到右图列表中General类别通用,选择Switch Default Voice ,然后单击列表项目的右边缘内。~/.SwitchDefaultVoice-rc 。该服务提供了切换默认语音的替代方法:它以固定的替代语音在最前面的应用程序中说所选的文本,这允许它与内置的说话式启用式文本服务一起使用,该服务始终使用默认语音(请参阅System Preferences > Dictation & Speech > Text to Speech )。
通常,您会使用此服务来讲所选的文本,语音说另一种语言。
您可以从“标准Services菜单,类别Text ,每当在最初的应用程序中选择文本时调用它,或通过System Preferences > Keyboard > Shortcuts > Services分配键盘快捷键;例如, ⌥` (opt-`)与内置服务的默认快捷方式平行, ⌥⎋ (opt-esc)。
再次调用服务,而先前调用的文字仍在说中止。
警告:仅当在再次调用服务时,在激活应用中选择文本 -任何文本 - 任何文本。
如果需要,您可以复制该服务,以便能够与多种替代声音交谈:
安装后,重复~/Library/Services/Speak With Specific Voice.workflow 。
Speak With Specific Voice.workflow 。Speak With Specific Voice.workflow ,然后在提示时选择Install - 这将把软件包放入~/Library/Services/ 。Open in Automator ,并在下面进行自定义。 # ------- BEGIN: CUSTOMIZE和# ------- END: CUSTOMIZE 。System Preferences > Keyboard > Shortcuts ,类别Services ,滚动到右图列表中的子General通用,请选择Speak With Specific Voice.workflow ,然后单击列表项目的右边缘内。~/Library/Services/Speak With Specific Voice.workflow 。~/Library ,请激活Finder,选择Go菜单时按住选项键,然后选择Library ;从那里,导航到子文件夹Services ,并Speak With Specific Voice.workflow 。版权所有(C)2015-2018 Michael Klement [email protected](http://same2u.net),根据MIT许可发布。
根据其各自的许可条款,该项目非常依赖以下开源组件。
下面的NPM依赖性具有表示依赖类型的可选后缀;没有后缀表示所需的运行时依赖性: (D)表示仅开发时间的依赖性, (O)可选依赖性和(P)同行依赖性。
版本控制符合语义版本控制(SEMVER)。
v0.3.4 (2018-03-21):
V0.3.3 (2018-03-08):
awk标准实用程序的系统版本,以防止被调用/usr/local/bin中的用户安装版本引起的意外行为。v0.3.2 (2017-01-03):
voices -m现在在Macos Sierra上工作。v0.3.1 (2015-11-03):
V0.3.0 (2015-10-27):
-i用于报告语音内部词的I现在报告一个额外的可变BundleID ,即最后一项,即语音的捆绑包ID。V0.2.3 (2015-09-20):
voices现在有一个人页面(如果手动安装,请使用voices --man ); voices -h现在只打印简明的用法信息。V0.2.2 (2015-09-15):
v0.2.1 (2015-07-30):
V0.2.0 (2015-07-29):
voices在要求与-k选项交谈时会尊重自定义说话费率Switch Default Voice.workflow现在基于配置文件,并支持2个以上的周期性开关声音;默认确认文本在交换上说明是新语音语言的本地名称。Speak With Specific Voice.workflow允许使用固定的替代语音说话的文本。V0.1.9 (2015-07-28):
V0.1.8 (2015-07-28):
V0.1.7 (2015-07-28):
say实用程序的限制,带有voices自己的-k选项的讲话并不符合自定义说话费率。V0.1.6 (2015-07-28):
V0.1.5 (2015-07-27):
V0.1.4 (2015-07-27):
V0.1.3 (2015-07-06):
--version的措辞。V0.1.2 (2015-07-01):
V0.1.1 (2015-06-30):
V0.1.0 (2015-06-29):