Tại sao nên lựa chọn FPT.AI Text To Speech
Giọng đọc tự nhiên, đa dạng vùng miền
Dịch vụ FPT.AI TTS cung cấp phản hồi bằng giọng nói tự nhiên, tự động ngắt nghỉ khi đọc câu dài, kết hợp biểu cảm ngữ điệu. Sản phẩm được phát triển dành riêng cho thị trường Việt Nam, dựa trên những nghiên cứu chuyên sâu về giọng nói của từng khu vực. FPT.AI TTS hiện có 7 giọng đọc, đến từ nhiều khu vực khác nhau trên khắp Việt Nam.
Bắt đầuKết nối dễ dàng
Bạn có thể kết nối với API của FPT.AI hoặc chuyển đổi văn bản trực tiếp trên giao diện người dùng của website thành các file âm thanh với các định dạng thông dụng như MP3, WAV,…
Bắt đầuPhản hồi nhanh chóng
API của FPT.AI có thể nhanh chóng đáp ứng mọi yêu cầu về quy mô của người dùng, đáp ứng nhu cầu tải đột biến của hệ thống.
Bắt đầuBảng Giá
Miễn Phí
100,000 ký tự/thángKhông phát sinh chi phí khác
- Không hỗ trợ kĩ thuật
Miễn Phí
Lựa chọnThương mại
Thanh toán cho dung lượng thực tế sử dụngKhông phát sinh chi phí khác
- Tốc độ chuyển đổi cao
từ 500,000 đ / tháng
Lựa chọnDoanh Nghiệp
Vui lòng liên hệ chúng tôi để biết thông tin chi tiết
- Hỗ Trợ Kỹ Thuật
Liên Hệ
*Báo giá trên chưa bao gồm: Thuế và các loại phí liên quan và phát triển các tính năng riêng cho doanh nghiệp
property nameValueDescriptiontextStringtext đầu vào cần tổng hợp.voiceStringgiọng đọc muốn tổng hợp.idStringID request do người dụng đặt [có thể dùng để traceback].without_filterBooleancó sử dụng filter để tăng chất lượng giọng hay không [chậm hơn].speedFloattốc độ giọng [có giá trị 0.7 – 1.3, tương ứng tốc độ đọc từ x0.7 đến x1.3 lần].tts_return_optionIntergermột số dạng integer để chọn api như sau:1: streaming2: wav3: mp3
Success Response:
- Code: 200
- Content: inputstream [audio wav format]
Giọng đọc hiện có
Mã giọng đọcMô tảhn-quynhanhGiọng nữ miền Bắc chất lượng caohcm-diemmyGiọng nữ miền Nam chất lượng caohue-maingocGiọng nữ miền Trung chất lượng caohn-phuongtrangGiọng nữ miền Bắc chất lượng caohn-thanhtungGiọng nam miền Bắchue-baoquocGiọng nam miền Trunghcm-minhquanGiọng nam miền NamtrinhthiviettrinhGiọng nữ miền BắclethiyenGiọng nữ miền NamnguyenthithuyduyenGiọng nữ miền NamphamtienquanGiọng nam miền Bắc
Bạn có thể lấy danh sách giọng đọc mới nhất thông qua API: //viettelgroup.ai/voice/api/tts/v1/rest/voices
Text-to-speech Web API chuyển văn bản thành giọng nói của Tubekit giúp bạn truy xuất vào công nghệ chuyển văn bản sang giọng nói audio để mở rộng ứng dụng của bạn.Để truy cập và kết nối vào nền tảng API, bạn cần sử dụng gói "Chuyên Nghiệp" trở lên. Xem bảng giá chi tiết tại đây.
Nội dung chính
Đầu tiên bạn cần có API KEY để có thể truy cập vào Text-to-speech API.
Để tạo API KEY, bạn bấm vào liên kết " API KEY" ở menu bên trái.
Tiếp theo, bấm vào nút "Tạo API KEY" màu xanh, đặt tên cho dự án ở phần KEY Name, sau đó bấm nút "Create"
Khi đã tạo KEY xong, bạn bấm vào nút "Copy" bên cạnh KEY để copy API-KEY vào clipboard. Để bật / tắt API, bạn bấm nút ON/OFF
Sau khi có được API-KEY, bạn dùng Key này để làm chìa khóa truy cập vào API
URL Endpoint text-to-speech:
//www.tubekit.win/api/v1/tts/synthesize
Method
http POST
Header Parameters
{ "status": "success", "mess": "success", "audioData": "//PIxAAAAANIAAAAAExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV.................." }
0{ "status": "success", "mess": "success", "audioData": "//PIxAAAAANIAAAAAExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV.................." }
1
Định dạng data gửi lên: Json [default], ví dụ:
{ "text": "Chào mừng các bạn đến với công cụ chuyển đổi văn bản thành giọng nói của Tubekit. Đây là Text to speech tiếng việt", "voiceServer": "ttsvnpro", "voiceID": "vi-VN2", "voiceSpeed": "0" }
Mô tả các thông số:
Thuộc tínhkiểu dữ liệuMô tảtextStringinput văn bản cần chuyển sang giọng nói, có thể là text thuần, hoặc theo cấu trúc SSMLvoiceServerStringServer giọng đọc, hiện tại chúng tôi cung cấp 3 server chính bao gồm: ttsvnpro, ttsbin và ttsgovoiceIDStringDanh sách giọng đọc [voiceID] và voiceServer được cung cấp ở link này:
//www.tubekit.win/api/v1/tts/voicesvoiceSpeedString[ Tốc độ giọng nói ]
- -3 : rất chậm
- -2 : khá chậm
- -1 : chậm
- 0 : Bình thường [ default ]
- 1 : nhanh
- 2 : khá nhanh
- 3 : rất nhanh
Dữ liệu trả về:
- Code: 200
- status: success
- mess: success
- audioData: Dữ liệu đầu ra mp3 [ định dạng base64 ]
Ví dụ về phản hồi thành công [ response success ] :
{ "status": "success", "mess": "success", "audioData": "//PIxAAAAANIAAAAAExBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV.................." }
Text-to-speech api cURL
Code:curl --request POST \ --url //www.tubekit.win/api/v1/tts/synthesize \ --header "apikey: YOUR-API-KEY" \ --header "Content-Type: application/json" \ --data "{\"voiceServer\": \"ttsbin\", \"voiceID\": \"vi-VN2\", \"voiceSpeed\": \"0\", \"text\": \"Đây là API Text to speech tiếng việt\"}"
Text-to-speech api PHP
Code example:
$curl = curl_init[]; curl_setopt_array[$curl, array[ CURLOPT_URL => "//www.tubekit.win/api/v1/tts/synthesize", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\r\n \"text\": \"Đây là API text to speech tiếng việt\",\r\n \"voiceServer\": \"ttsbin\",\r\n \"voiceID\": \"vi-VN2\",\r\n \"voiceSpeed\": \"0\"\r\n}", CURLOPT_HTTPHEADER => array[ "apikey: YOUR-API-KEY", "content-type: application/json" ], ]]; $response = curl_exec[$curl]; $err = curl_error[$curl]; curl_close[$curl]; if [$err] { echo "cURL Error #:" . $err; } else { echo $response; }
Text-to-speech api Python
Code example:#!/usr/bin/env python # -*- coding: utf-8 -*- # Import the json library import json import requests import urllib import base64 url = "//www.tubekit.win/api/v1/tts/synthesize" data = {"voiceServer": "ttsbin", "voiceID": "vi-VN2", "voiceSpeed": "0", "text": "Đây là API Text to speech tiếng việt"} headers = {'Content-type': 'application/json', 'apikey': 'YOUR-API-KEY'} response = requests.post[url, data=json.dumps[data], headers=headers] #if encounter SSL error because of https certificate, please comment out above line and use the line below to make insecure connections [this will expose your application to security risks, such as man-in-the-middle attacks.] #response = requests.post[url, data=json.dumps[data], headers=headers, verify=False] # Headers is a dictionary #print[response.headers] # Get status_code. #print[response.status_code] # Get the response data as a python object. data = response.content jData = json.loads[response.content] #print[data] #print[data.audioData] #print[jData["audioData"]] if jData["status"] == "error": print["Error: "] print[jData["mess"]] else: wav_data = base64.b64decode[jData["audioData"]] #print[wav_data] f = open["output.mp3", "wb"] f.write[wav_data] f.close[] print["Text to speech convert success. Please open output.mp3 file and enjoy!"]
Text to speech api Java
Code example:URL url = new URL["//www.tubekit.win/api/v1/tts/synthesize"]; HttpURLConnection http = [HttpURLConnection]url.openConnection[]; http.setRequestMethod["POST"]; http.setDoOutput[true]; http.setRequestProperty["apikey", "YOUR-API-KEY"]; http.setRequestProperty["Content-Type", "application/json"]; String data = "{\"voiceServer\": \"ttsbin\", \"voiceID\": \"vi-VN2\", \"voiceSpeed\": \"0\", \"text\": \"Đây là API Text to speech tiếng việt\"}"; byte[] out = data.getBytes[StandardCharsets.UTF_8]; OutputStream stream = http.getOutputStream[]; stream.write[out]; System.out.println[http.getResponseCode[] + " " + http.getResponseMessage[]]; http.disconnect[];
Text to speech api Javascript/AJAX
Code example:var url = "//www.tubekit.win/api/v1/tts/synthesize"; var xhr = new XMLHttpRequest[]; xhr.open["POST", url]; xhr.setRequestHeader["apikey", "YOUR-API-KEY"]; xhr.setRequestHeader["Content-Type", "application/json"]; xhr.onreadystatechange = function [] { if [xhr.readyState === 4] { console.log[xhr.status]; console.log[xhr.responseText]; }}; var data = '{"voiceServer": "ttsbin", "voiceID": "vi-VN2", "voiceSpeed": "0", "text": "Đây là API Text to speech tiếng việt"}'; xhr.send[data];
Text to speech api C#/.NET
Code example:var url = "//www.tubekit.win/api/v1/tts/synthesize"; var httpRequest = [HttpWebRequest]WebRequest.Create[url]; httpRequest.Method = "POST"; httpRequest.Headers["apikey"] = "YOUR-API-KEY"; httpRequest.ContentType = "application/json"; var data = "{\"voiceServer\": \"ttsbin\", \"voiceID\": \"vi-VN2\", \"voiceSpeed\": \"0\", \"text\": \"Đây là API Text to speech tiếng việt\"}"; using [var streamWriter = new StreamWriter[httpRequest.GetRequestStream[]]] { streamWriter.Write[data]; } var httpResponse = [HttpWebResponse]httpRequest.GetResponse[]; using [var streamReader = new StreamReader[httpResponse.GetResponseStream[]]] { var result = streamReader.ReadToEnd[]; } Console.WriteLine[httpResponse.StatusCode];