0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VoiceText Web APIをpythonから呼び出してみる

Posted at

VoiceText Web APIをpythonから呼び出してみる際の備忘メモです

VoiceText Web API 登録&APIキー取得

VoiceText Web API

※利用の際は以下に留意しましょう
利用規約をご確認の上、本サービスをご利用ください。

お試し(curl)

introductionが充実しており参照させて頂く

curl "https://api.voicetext.jp/v1/tts" \
    -o "test.wav" \
    -u "YOUR_API_KEY:" \
    -d "text=おはようございます" \
    -d "speaker=hikari"

お試し(python)

ライブラリのインストール

pip install python-voicetext

VoiceText Web APIをPythonで使ってみる

#coding:utf-8
 
from requests_toolbelt import SSLAdapter
import requests
import ssl
import sys
 
url = 'https://api.voicetext.jp/v1/tts'
API_KEY = 'YOUR API KEY'
 
payload = {
    'text': 'おはようございます',
    'speaker': 'hikari',
    }
 
s = requests.Session()
s.mount(url, SSLAdapter(ssl.PROTOCOL_TLSv1))
r = s.post(url, params=payload, auth=(API_KEY,''))
 
print "status code:", r.status_code
if r.status_code != 200:
    print "error:", r.json()['error']['message']
    sys.exit()
 
f = open("test.wav", 'wb')
f.write(r.content)
f.close()

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?