LoginSignup
2
6

More than 3 years have passed since last update.

棒読みちゃんをPythonから喋らせる(http連携)

Last updated at Posted at 2021-05-22

経緯

WEBカメラの映像をリアルタイム解析し、何かあったら棒読みちゃんに喋らせる、というプログラムを画策していた。その中の喋らせる部分のピンポイントな記事がPythonだと見当たらなかったので書いてみた。

まとめ

喋らせたい内容とかをURLパラメータにした上でrequestsモジュールで棒読みちゃんのhttpサーバにGETリクエスト送るだけ。

開発環境

  • Windows 10 Home 21H1 64bit
  • Python 3.9.4
  • 棒読みちゃん Ver0.1.11.0 Beta21

コード

棒読みちゃんを事前に立ち上げた上で以下を実行すると多分喋り出します。
requestsモジュールは事前にpipとかでインストールして下さい。GETリクエスト送れればいいのでurllibモジュールでもおそらく出来ます。
棒読みちゃんのサーバポート変えてたら適宜修正して下さい。

import requests


def speak_bouyomi(text='ゆっくりしていってね', voice=0, volume=-1, speed=-1, tone=-1):
    res = requests.get(
        'http://localhost:50080/Talk',
        params={
            'text': text,
            'voice': voice,
            'volume': volume,
            'speed': speed,
            'tone': tone})
    return res.status_code


if __name__ == "__main__":
    print(speak_bouyomi('あいうえお'))

参考

2
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6