지원되는 모든 음성 나열

API의 voices:list 엔드포인트를 호출하면 지원되는 모든 음성의 전체 목록을 가져올 수 있습니다. 또한 지원되는 음성 페이지에서 사용할 수 있는 음성의 전체 목록을 확인할 수 있습니다.

다음 코드 스니펫은 Text-to-Speech API에서 텍스트 음성 변환 합성에 사용할 수 있는 음성을 나열하는 방법을 보여줍니다.

이 샘플을 사용하려면 Google Cloud CLI를 설치하고 초기화해야 합니다. gcloud CLI 설정에 대한 자세한 내용은 TTS에 인증을 참조하세요.

프로토콜

자세한 내용은 voices:list API 엔드포인트를 참조하세요.

TTS(텍스트 음성 변환) 합성에 사용 가능한 음성 목록을 보려면 voices:list API 엔드포인트에 GET 요청을 수행하세요. PROJECT_ID는 프로젝트 ID로 바꿉니다.

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \     -H "x-goog-user-project: PROJECT_ID" \     -H "Content-Type: application/json; charset=utf-8" \     "https://texttospeech.googleapis.com/v1/voices"

Text-to-Speech API는 다음과 비슷한 JSON 형식의 결과를 반환합니다.

 {   "voices": [     {       "languageCodes": [         "es-ES"       ],       "name": "es-ES-Standard-A",       "ssmlGender": "FEMALE",       "naturalSampleRateHertz": 24000     },     {       "languageCodes": [         "ja-JP"       ],       "name": "ja-JP-Standard-A",       "ssmlGender": "FEMALE",       "naturalSampleRateHertz": 22050     },     {       "languageCodes": [         "pt-BR"       ],       "name": "pt-BR-Standard-A",       "ssmlGender": "FEMALE",       "naturalSampleRateHertz": 24000     },         ...   ] } 

Go

Text-to-Speech용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Text-to-Speech 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Text-to-Speech Go API 참고 문서를 확인하세요.

Text-to-Speech에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

 // ListVoices lists the available text to speech voices. func ListVoices(w io.Writer) error { 	ctx := context.Background()  	client, err := texttospeech.NewClient(ctx) 	if err != nil { 		return err 	} 	defer client.Close()  	// Performs the list voices request. 	resp, err := client.ListVoices(ctx, &texttospeechpb.ListVoicesRequest{}) 	if err != nil { 		return err 	}  	for _, voice := range resp.Voices { 		// Display the voice's name. Example: tpc-vocoded 		fmt.Fprintf(w, "Name: %v\n", voice.Name)  		// Display the supported language codes for this voice. Example: "en-US" 		for _, languageCode := range voice.LanguageCodes { 			fmt.Fprintf(w, "  Supported language: %v\n", languageCode) 		}  		// Display the SSML Voice Gender. 		fmt.Fprintf(w, "  SSML Voice Gender: %v\n", voice.SsmlGender.String())  		// Display the natural sample rate hertz for this voice. Example: 24000 		fmt.Fprintf(w, "  Natural Sample Rate Hertz: %v\n", 			voice.NaturalSampleRateHertz) 	}  	return nil } 

Java

Text-to-Speech용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Text-to-Speech 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Text-to-Speech Java API 참고 문서를 확인하세요.

Text-to-Speech에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**  * Demonstrates using the Text to Speech client to list the client's supported voices.  *  * @throws Exception on TextToSpeechClient Errors.  */ public static List<Voice> listAllSupportedVoices() throws Exception {   // Instantiates a client   try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {     // Builds the text to speech list voices request     ListVoicesRequest request = ListVoicesRequest.getDefaultInstance();      // Performs the list voices request     ListVoicesResponse response = textToSpeechClient.listVoices(request);     List<Voice> voices = response.getVoicesList();      for (Voice voice : voices) {       // Display the voice's name. Example: tpc-vocoded       System.out.format("Name: %s\n", voice.getName());        // Display the supported language codes for this voice. Example: "en-us"       List<ByteString> languageCodes = voice.getLanguageCodesList().asByteStringList();       for (ByteString languageCode : languageCodes) {         System.out.format("Supported Language: %s\n", languageCode.toStringUtf8());       }        // Display the SSML Voice Gender       System.out.format("SSML Voice Gender: %s\n", voice.getSsmlGender());        // Display the natural sample rate hertz for this voice. Example: 24000       System.out.format("Natural Sample Rate Hertz: %s\n\n", voice.getNaturalSampleRateHertz());     }     return voices;   } }

Node.js

Text-to-Speech용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Text-to-Speech 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Text-to-Speech Node.js API 참고 문서를 확인하세요.

Text-to-Speech에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

const textToSpeech = require('@google-cloud/text-to-speech');  const client = new textToSpeech.TextToSpeechClient();  const [result] = await client.listVoices({}); const voices = result.voices;  console.log('Voices:'); voices.forEach(voice => {   console.log(`Name: ${voice.name}`);   console.log(`  SSML Voice Gender: ${voice.ssmlGender}`);   console.log(`  Natural Sample Rate Hertz: ${voice.naturalSampleRateHertz}`);   console.log('  Supported languages:');   voice.languageCodes.forEach(languageCode => {     console.log(`    ${languageCode}`);   }); });

Python

Text-to-Speech용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Text-to-Speech 클라이언트 라이브러리를 참조하세요. 자세한 내용은 Text-to-Speech Python API 참고 문서를 확인하세요.

Text-to-Speech에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

def list_voices():     """Lists the available voices."""     from google.cloud import texttospeech      client = texttospeech.TextToSpeechClient()      # Performs the list voices request     voices = client.list_voices()      for voice in voices.voices:         # Display the voice's name. Example: tpc-vocoded         print(f"Name: {voice.name}")          # Display the supported language codes for this voice. Example: "en-US"         for language_code in voice.language_codes:             print(f"Supported language: {language_code}")          ssml_gender = texttospeech.SsmlVoiceGender(voice.ssml_gender)          # Display the SSML Voice Gender         print(f"SSML Voice Gender: {ssml_gender.name}")          # Display the natural sample rate hertz for this voice. Example: 24000         print(f"Natural Sample Rate Hertz: {voice.natural_sample_rate_hertz}\n")  

추가 언어

C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 후 .NET용 Text-to-Speech 참고 문서를 참조하세요.

PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 후 PHP용 Text-to-Speech 참고 문서를 참조하세요.

Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 후 Ruby용 Text-to-Speech 참고 문서를 참조하세요.