Chirp 3: 즉석 커스텀 음성

Text-to-Speech의 즉석 커스텀 음성을 사용하면 사용자가 자체 고품질 오디오 녹음으로 모델을 학습시켜 맞춤 음성 모델을 만들 수 있습니다. 이를 통해 개인 음성을 빠르게 생성할 수 있으며, 생성된 음성은 스트리밍 및 긴 형식의 텍스트를 모두 지원하는 Cloud TTS API를 사용하여 오디오를 합성하는 데 사용할 수 있습니다.

안전을 위한 고려사항으로 인해 이 음성 클론 기능에 대한 액세스는 허용 목록에 등록된 사용자로 제한됩니다. 이 기능에 액세스하려면 허용 목록에 추가될 수 있도록 영업팀 담당자에게 연락하세요.

Colab 노트북 사용해 보기 GitHub에서 노트북 보기

스크립트 작성 지원 언어

즉석 커스텀 음성 생성 및 합성은 다음 언어로 지원됩니다.

언어 BCP-47 코드
아랍어(XA) ar-XA
중국어(중국) cmn-CN
독일어(독일) de-DE
영어(호주) en-AU
영어(영국) en-GB
영어(인도) en-IN
영어(미국) en-US
스페인어(스페인) es-ES
스페인어(미국) es-US
프랑스어(캐나다) fr-CA
프랑스어(프랑스) fr-FR
구자라트어(인도) gu-IN
힌디어(인도) hi-IN
인도네시아어(인도네시아) id-ID
이탈리아어(이탈리아) it-IT
한국어(대한민국) ko-KR
마라티어(인도) mr-IN
네덜란드어(네덜란드) nl-NL
폴란드어(폴란드) pl-PL
포르투갈어(브라질) pt-BR
러시아어(러시아) ru-RU
타밀어(인도) ta-IN
텔루구어(인도) te-IN
태국어(태국) th-TH
터키어(터키) tr-TR
베트남어(베트남) vi-VN

사용 가능한 리전

즉석 커스텀 음성 생성 및 합성은 다음 Google Cloud 리전에서 각각 사용할 수 있습니다.

Google Cloud 영역 지원되는 방법 출시 준비
global 생성, 합성 비공개 미리보기
us 가공 비공개 미리보기
eu 가공 비공개 미리보기
asia-southeast1 가공 비공개 미리보기

지원되는 출력 형식

기본 응답 형식은 LINEAR16이지만 지원되는 다른 형식은 다음과 같습니다.

API 메서드 형식
streaming OGG_OPUS 및 PCM
batch ALAW, MULAW, MP3, OGG_OPUS, PCM

기능 지원 및 제한사항

기능 지원 설명
SSML 아니요 합성 오디오 맞춤설정을 위한 SSML 태그
텍스트 기반 프롬프트 작성 실험용 구두점, 일시중지, 말더듬을 사용하여 Text-to-Speech에 자연스러운 흐름과 속도를 더합니다.
타임스탬프 아니요 단어 수준 타임스탬프
일시중지 태그 아니요 합성 오디오에 주문형 일시중지 도입
속도 제어 아니요 합성된 오디오의 속도를 0.25배에서 2배로 조정합니다.
발음 제어 아니요 IPA 또는 X-SAMPA 음성 인코딩을 사용한 단어 또는 문구의 커스텀 발음

Chirp 3 사용: 즉석 커스텀 음성

Text-to-Speech API에서 Chirp 3: 즉석 커스텀 음성 기능을 사용하는 방법 알아보기

즉석 커스텀 음성 만들기

import requests, os, json

def create_instant_custom_voice_key(
    access_token, project_id, reference_audio_bytes, consent_audio_bytes
):
    url = "https://texttospeech.googleapis.com/v1beta1/voices:generateVoiceCloningKey"

    request_body = {
        "reference_audio": {
            "audio_config": {"audio_encoding": "LINEAR16", "sample_rate_hertz": 24000},
            "content": reference_audio_bytes,
        },
        "voice_talent_consent": {
            "audio_config": {"audio_encoding": "LINEAR16", "sample_rate_hertz": 24000},
            "content": consent_audio_bytes,
        },
        "consent_script": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
        "language_code": "en-US",
    }

    try:
        headers = {
            "Authorization": f"Bearer {access_token}",
            "x-goog-user-project": project_id,
            "Content-Type": "application/json; charset=utf-8",
        }

        response = requests.post(url, headers=headers, json=request_body)
        response.raise_for_status()

        response_json = response.json()
        return response_json.get("voiceCloningKey")

    except requests.exceptions.RequestException as e:
        print(f"Error making API request: {e}")
    except json.JSONDecodeError as e:
        print(f"Error decoding JSON response: {e}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

즉석 커스텀 음성으로 합성

import requests, os, json, base64
from IPython.display import Audio, display

def synthesize_text_with_cloned_voice(access_token, project_id, voice_key, text):
    url = "https://texttospeech.googleapis.com/v1beta1/text:synthesize"

    request_body = {
        "input": {
            "text": text
        },
        "voice": {
            "language_code": "en-US",
            "voice_clone": {
                "voice_cloning_key": voice_key,
            }
        },
        "audioConfig": {
            "audioEncoding": "LINEAR16",
            "sample_rate_hertz": 24000
        }
    }

    try:
        headers = {
            "Authorization": f"Bearer {access_token}",
            "x-goog-user-project": project_id,
            "Content-Type": "application/json; charset=utf-8"
        }

        response = requests.post(url, headers=headers, json=request_body)
        response.raise_for_status()

        response_json = response.json()
        audio_content = response_json.get("audioContent")

        if audio_content:
            display(Audio(base64.b64decode(audio_content), rate=24000))
        else:
            print("Error: Audio content not found in the response.")
            print(response_json)

    except requests.exceptions.RequestException as e:
        print(f"Error making API request: {e}")
    except json.JSONDecodeError as e:
        print(f"Error decoding JSON response: {e}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")