內容
[重要:與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
如果您使用兩種或多種語言的文本到語音,並且希望快速在多個指定的聲音之間循環地將默認的語音轉換,則使用嵌入式聲音副本,它將與內置的Speak-Seal-Selected- voices 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):