Views
No views yet
1import requests
2import base64
3
4url = "https://j3meo1ty1iv2knlo.us-east-1.aws.endpoints.huggingface.cloud"
5headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
6
7# 基本的な日本語音声生成
8data = {
9 "inputs": "こんにちは、私はStyle-BERT-VITS2です。",
10 "parameters": {
11 "emotion": "neutral",
12 "speed": 1.0,
13 "pitch": 0.0,
14 "volume": 1.0
15 }
16}
17
18response = requests.post(url, headers=headers, json=data)
19result = response.json()
20
21# 音声ファイル保存
22if result and "audio_base64" in result[0]:
23 audio_data = base64.b64decode(result[0]["audio_base64"])
24 with open("output.wav", "wb") as f:
25 f.write(audio_data)
26 print(f"音声時間: {result[0]['duration']:.2f}秒")1curl -X POST "https://j3meo1ty1iv2knlo.us-east-1.aws.endpoints.huggingface.cloud" \
2 -H "Authorization: Bearer YOUR_HF_TOKEN" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "inputs": "今日はとても嬉しい気分です!",
6 "parameters": {
7 "emotion": "happy",
8 "speed": 1.1,
9 "pitch": 1.0,
10 "volume": 0.9
11 }
12 }'| パラメータ | 範囲 | デフォルト | 説明 |
|---|---|---|---|
emotion | neutral, happy, sad, angry | neutral | 感情表現 |
speed | 0.5-2.0 | 1.0 | 話速 |
pitch | -12.0 to 12.0 | 0.0 | ピッチ(セミトーン) |
volume | 0.0-2.0 | 1.0 | 音量 |
speaker_id | 0-3 | 0 | 話者ID |
1# 嬉しい感情
2{"inputs": "素晴らしい結果です", "parameters": {"emotion": "happy"}}
3# → "素晴らしい結果です!" (感嘆符自動追加)
4
5# 悲しい感情
6{"inputs": "少し寂しいです", "parameters": {"emotion": "sad"}}
7# → "少し寂しいです…" (語尾調整)1[
2 {
3 "audio_base64": "UklGRi4AAABXQVZFZm10...",
4 "sample_rate": 22050,
5 "duration": 3.78,
6 "text": "こんにちは、私はStyle-BERT-VITS2です。",
7 "parameters_used": {...},
8 "model_info": {
9 "name": "Style-BERT-VITS2-Production",
10 "version": "gTTS-Japanese",
11 "tts_engine": "Google TTS",
12 "device": "cuda"
13 }
14 }
15]