Download OpenAPI specification:Download
API Changelog
This is CoeFont's REST API.
Please obtain the access key and access secret from Account Settings → API Information Page.
When using CoefontAPI, it must be signed using HMAC-SHA256.
Please set the header appropriately based on the following specification.
ヘッダー | 詳細 |
---|---|
X-Coefont-Date | UNIX time (UTC) |
X-Coefont-Content | String representing the result of hashing the following data with HMAC-SHA256 using the access secret in hex format - UNIX time(UTC) - Request body |
Authorization | access key |
Content-Type | application/json |
The following flow is used to hash the data.
import hmac
import requests
import hashlib
import json
from datetime import datetime, timezone
accesskey = 'QY4Tuiug6XidAKjDS5zTQHGSI'
access_secret = '62A03zCgPflc3NZwFHliphpKFt4tppOpdmUHgqPR'
text = 'これはテストです。'
date: str = str(int(datetime.utcnow().replace(tzinfo=timezone.utc).timestamp()))
data: str = json.dumps({
'coefont': '2b174967-1a8a-42e4-b1ae-5f6548cfa05d',
'text': text
})
signature = hmac.new(bytes(access_secret, 'utf-8'), (date+data).encode('utf-8'), hashlib.sha256).hexdigest()
response = requests.post('https://api.coefont.cloud/v2/text2speech', data=data, headers={
'Content-Type': 'application/json',
'Authorization': accesskey,
'X-Coefont-Date': date,
'X-Coefont-Content': signature
})
if response.status_code == 200:
with open('response.wav', 'wb') as f:
f.write(response.content)
else:
print(response.json())
Converts text to synthesized speech. If both yomi
and accent
are specified, the reading accent is converted to synthesized speech (only Japanese CoeFont supports yomi
accent
parameter). English CoeFont can be read out in English, and Chinese CoeFont can be read out in Chinese only.
Content-Type required | string Content-Type |
Authorization required | string access key |
X-Coefont-Date required | string UNIX time (UTC) |
X-Coefont-Content required | string A string signed with an access secret. |
Text
coefont required | string ID of the CoeFont that performs the audio conversion. Refer to the individual uuid displayed in the url of the CoeFont detail screen. |
text required | string [ 1 .. 1000 ] characters Text to be converted to speech |
yomi | string non-empty Reading of the text (Japanese only) |
accent | string non-empty The accent is represented by a string consisting of 1 and 2, where 1 is the low tone and 2 is the high tone. It corresponds to each letter of the reading (yomi) and forward, and the length of the string is the same. (Japanese only) |
speed | number <float> [ 0.1 .. 10 ] Default: 1 Audio speed. 1.0 for normal speed, 0.5 for half speed, and 2.0 for double speed. |
pitch | number <float> [ -3000 .. 3000 ] Default: 0 Pitch of speech. Changes by one octave at ±1200. |
kuten | number <float> [ 0 .. 5 ] Default: 0.7 Punctuation interval (sec) |
toten | number <float> [ 0.2 .. 2 ] Default: 0.4 Reading Interval (sec) |
volume | number <float> [ 0.2 .. 2 ] Default: 1 Volume (magnification) |
intonation | number <float> [ 0 .. 2 ] Default: 1 inflection |
format | string Enum: "wav" "mp3" Audio file format |
{- "coefont": "1f58f1ae-2e9c-443a-9e3c-60d8e5dee3b8",
- "text": "これはテストです",
- "yomi": "これはてすとです。",
- "accent": "122221221",
- "speed": 1,
- "pitch": 0,
- "kuten": 0.7,
- "toten": 0.4,
- "volume": 1,
- "intonation": 1,
- "format": "wav"
}
{- "message": "error message"
}
Converts text together into synthetic speech. The total number of characters should be no more than about 1000.
Content-Type required | string Content-Type |
Authorization required | string accesskey |
X-Coefont-Date required | string UNIX time |
X-Coefont-Content required | string A string signed with an access secret. |
Text
required | Array of objects (PostText2SpeechBatchOne) non-empty An array specifying the text to be converted to speech and the CoeFont. |
format | string Enum: "wav" "mp3" The format of the audio file to be output. wav or mp3. |
{- "data": [
- {
- "coefont": "1f58f1ae-2e9c-443a-9e3c-60d8e5dee3b8",
- "text": "これはテストです",
- "speed": 1,
- "pitch": 0,
- "kuten": 0.7,
- "toten": 0.4,
- "volume": 1,
- "intonation": 1
}
], - "format": "wav"
}
{- "message": "error message"
}
Get a list of user dictionaries
category | string category |
Content-Type required | string Content-Type |
Authorization required | string access key |
X-Coefont-Date required | string UNIX time(UTC) |
X-Coefont-Content required | string A string signed with an access secret. |
[- {
- "text": "ユーザー辞書",
- "category": "カテゴリー",
- "yomi": "ゆーざーじしょ",
- "accent": "1222212"
}
]
Add an item to the user dictionary. If there are duplicate words and categories, they will be overwritten.
Content-Type required | string Content-Type |
Authorization required | string access key |
X-Coefont-Date required | string UNIX time(UTC) |
X-Coefont-Content required | string A string signed with an access secret. |
User dictionary items
text required | string [ 1 .. 100 ] characters Words to add to the dictionary |
category required | string non-empty category |
yomi required | string [ 1 .. 100 ] characters Yomi (Hiragana or Katakana) |
accent | string non-empty The accent is represented by a string consisting of 1 and 2, where 1 is the low tone and 2 is the high tone. It corresponds to each letter of the reading (yomi) and forward, and the length of the string is the same. |
{- "text": "ユーザー辞書",
- "category": "カテゴリー",
- "yomi": "ゆーざーじしょ",
- "accent": "1222212"
}
{- "message": "error message"
}