V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
musray
V2EX  ›  Python

如何用python脚本启动mac/terminal的朗读功能?

  •  
  •   musray · Jan 14, 2014 · 5863 views
    This topic created in 4499 days ago, the information mentioned may be changed or developed.
    我正在学日语,想用python写一个听写的脚本,但不知道如何可以实现:

    1. OS X 10.9,已经安装日语的语音包
    2. Python 2.7
    3. 功能需求:
    1)任意写一个list,里面包含所有我想听写的单词。
    2)python按10秒一个的速度,让terminal读出list中的单词。(这个到不必非在terminal里发音,我只是暂时想到这里)

    这个如果成功,那日语学习真的就是事半功倍啊!不知道是否可行?
    3 replies    1970-01-01 08:00:00 +08:00
    Livid
        1
    Livid  
    MOD
    PRO
       Jan 14, 2014   ❤️ 1
    from subprocess import call

    call(['say', 'hello'])
    tan9le
        2
    tan9le  
       Jan 14, 2014
    @Livid 哈哈,当时我们有个需求是同一个声源朗读1000多句文本,然后若干设备同时采集来比较解析偏差。实现过程想的超复杂,最后一个哥们幽幽的说:用call就可以了。。。
    musray
        3
    musray  
    OP
       Jan 14, 2014
    @Livid 这也太爽了吧!哈哈!

    from subprocess import call
    from time import sleep

    hiragana = {
    '1':'あ',
    '2':'い',
    '3':'う',
    }

    for word in hiragana:
    sleep(2.5)
    call(['say',hiragana[word]])
    sleep(2.5)
    call(['say',hiragana[word]])

    帮看看还能更简单么?!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   859 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:32 · PVG 04:32 · LAX 13:32 · JFK 16:32
    ♥ Do have faith in what you're doing.