Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/692fcfd8-4b44-800f-a184-fa098175a6d5
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== : ==== <syntaxhighlight lang="python"># generate_audio_gtts.py """ 使用說明: # 先安裝 gTTS: pip install gTTS # 確保此檔案與 hand_gesture_1_10.py 在同一層。 # 執行: python generate_audio_gtts.py # 會在 audio/ 底下產生: * zh_1.mp3 ~ zh_10.mp3 (國語) * tai_1.mp3 ~ tai_10.mp3(暫以國語念 POJ 文字,可自行換成更好的台語 TTS 或錄音覆蓋) """ from gtts import gTTS import os numbers_zh = { 1: "一", 2: "二", 3: "三", 4: "四", 5: "五", 6: "六", 7: "七", 8: "八", 9: "九", 10: "十", } numbers_tai = { 1: "it", 2: "nn̄g", 3: "saⁿ", 4: "sì", 5: "gō͘", 6: "la̍k", 7: "chhit", 8: "peh", 9: "káu", 10: "chap", } out_dir = "audio" os.makedirs(out_dir, exist_ok=True) === 產生國語音檔 === for n, word in numbers_zh.items(): text = f"{word}" # 只念數字本身 tts = gTTS(text=text, lang="zh-TW") fn = os.path.join(out_dir, f"zh_{n}.mp3") print("產生:", fn) tts.save(fn) === 產生「台語」音檔(實際仍用 zh-TW TTS 念 POJ 文字,可日後錄音覆蓋) === for n, word in numbers_tai.items(): text = f"台語 {word}" tts = gTTS(text=text, lang="zh-TW") fn = os.path.join(out_dir, f"tai_{n}.mp3") print("產生:", fn) tts.save(fn) print("全部產生完成!") </syntaxhighlight>
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)