Created
October 5, 2020 12:13
-
-
Save thejungwon/6f171a22df45f97329515e1fadbf6f0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import urllib.request | |
client_id = "<YOUR_CLIENT_ID>" | |
client_secret = "<YOUR_CLIENT_SECRET>" | |
encText = urllib.parse.quote(extracted_text) | |
data = "speaker=mijin&speed=0&text=" + encText; | |
url = "https://naveropenapi.apigw.ntruss.com/voice/v1/tts" | |
request = urllib.request.Request(url) | |
request.add_header("X-NCP-APIGW-API-KEY-ID",client_id) | |
request.add_header("X-NCP-APIGW-API-KEY",client_secret) | |
response = urllib.request.urlopen(request, data=data.encode('utf-8')) | |
rescode = response.getcode() | |
if(rescode==200): | |
print("TTS mp3 저장") | |
response_body = response.read() | |
with open('1111.mp3', 'wb') as f: | |
f.write(response_body) | |
else: | |
print("Error Code:" + rescode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment