Skip to content

Instantly share code, notes, and snippets.

@tatmos
Created December 27, 2021 17:47
Show Gist options
  • Save tatmos/0c13fcacad68c173c1c67fe69297a653 to your computer and use it in GitHub Desktop.
Save tatmos/0c13fcacad68c173c1c67fe69297a653 to your computer and use it in GitHub Desktop.
VOICEVOXの音声合成をするpythonスクリプト(VOICEVOXを起動した状態で実行)
# -*- coding: utf-8 -*-
import requests
import json
text = open('text.txt', encoding='utf-8').read()
#text = 'あいうえお'
query1 = requests.post('http://localhost:50021/audio_query', params={'speaker': '1', 'text': text})
#print(json.dumps(query1.json(), indent=2))
query2 = requests.post('http://localhost:50021/synthesis', headers={'content-type': 'application/json'},\
params={'speaker': '1'}, data=json.dumps(query1.json()))
with open('a.wav', mode='wb') as f:
f.write(query2.content)
@tatmos
Copy link
Author

tatmos commented Dec 27, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment