Utilisez SSML pour régler des caractéristiques vocales telles que le débit, la hauteur et le volume, et LaTeX pour lire des formules en chinois. Consultez les conditions, les exemples d’API, les balises et les symboles.
Présentation des fonctionnalités
SSML est un langage de balisage de synthèse vocale basé sur XML. Il permet de régler des caractéristiques vocales telles que la voix, le débit, la hauteur et le volume, de contrôler les pauses, de préciser la prononciation et la lecture, et d’ajouter de la musique de fond et des effets sonores. La fonction LaTeX de CosyVoice convertit les formules mathématiques du texte en parole chinoise.
Ces fonctions conviennent aux livres audio, aux annonces du service client, à la prononciation multilingue et à l’enseignement en ligne. Les modèles, voix et API disponibles sont indiqués ci-dessous. Pour choisir un modèle, consultez Synthèse vocale.
Conditions d’utilisation
SSML
-
Modèles pris en charge : qwen-audio-3.1-tts-plus, qwen-audio-3.1-tts-flash, qwen-audio-3.0-tts-flash, qwen-audio-3.0-tts-plus, cosyvoice-v3.5-flash, cosyvoice-v3.5-plus, cosyvoice-v3-flash, cosyvoice-v3-plus, cosyvoice-v2
-
Voix : Seules les voix clonées et les voix système indiquées comme compatibles avec SSML dans la liste des voix Qwen-Audio-TTS ou la liste des voix CosyVoice sont prises en charge.
-
API :
- SDK Java (version 2.20.3 ou ultérieure) : appels sans streaming ou avec streaming unidirectionnel
- SDK Python (version 2.0.1 ou ultérieure) : appels sans streaming ou avec streaming unidirectionnel
- API WebSocket : définissez
enable_ssmlsurtrueet envoyez un seul événement continue-task
LaTeX
-
Modèles pris en charge : cosyvoice-v3.5-plus, cosyvoice-v3.5-flash, cosyvoice-v3-plus, cosyvoice-v3-flash, cosyvoice-v2
-
Langue : chinois uniquement.
-
Contenu : utilisez les balises et symboles pris en charge. Les blocs de code mathématique Markdown, tels que les blocs marqués
math, ne sont pas pris en charge. Placez uniquement la formule entre les délimiteurs. Les autres textes peuvent être lus incorrectement.
Utilisation
SSML
Pour utiliser SSML, respectez les règles suivantes :
- Placez tout le texte dans
<speak></speak>. Plusieurs éléments<speak>peuvent se suivre, mais ne peuvent pas être imbriqués. - Échappez les caractères XML spéciaux dans les balises :
"→",'→',&→&,<→<et>→>.
Démarrage rapide
L'exemple ci-dessous utilise le format SSML pour contrôler la vitesse de parole lors de la synthèse. Avant d'exécuter le code, assurez-vous de remplir les conditions préalables suivantes :
- Obtenir une clé API
- Installez le SDK DashScope (Python 2.0.1 ou ultérieur, Java 2.20.3 ou ultérieur). Consultez Installer le SDK.
Importantcosyvoice-v3.5-plus et cosyvoice-v3.5-flash ne fournissent pas de voix prédéfinies. Pour utiliser l’un de ces modèles dans les exemples SSML de cette section, créez d’abord une voix clonée en suivant les instructions de Clonage vocal.
SDK Java
import com.alibaba.dashscope.audio.ttsv2.SpeechSynthesisParam;
import com.alibaba.dashscope.audio.ttsv2.SpeechSynthesizer;
import com.alibaba.dashscope.utils.Constants;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* SSML feature description:
* 1. Only non-streaming calls and unidirectional streaming calls support the SSML feature
* Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
*/
public class Main {
private static String model = "cosyvoice-v3-flash";
private static String voice = "longanyang";
public static void main(String[] args) {
// Singapore region URL. Replace WorkspaceId with your actual workspace ID. The URL varies by region.
Constants.baseWebsocketApiUrl = "wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference";
streamAudioDataToSpeaker();
System.exit(0);
}
public static void streamAudioDataToSpeaker() {
SpeechSynthesisParam param =
SpeechSynthesisParam.builder()
// The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured an environment variable, replace the following line with your Model Studio API Key: .apiKey("sk-xxx")
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.model(model)
.voice(voice)
.build();
SpeechSynthesizer synthesizer = new SpeechSynthesizer(param, null);
ByteBuffer audio = null;
try {
// Non-streaming call, blocks until audio is returned
// Special characters need to be escaped
audio = synthesizer.call("<speak rate=\"2\">My speaking rate is faster than a normal person's.</speak>");
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
// Close the WebSocket connection when the task ends
synthesizer.getDuplexApi().close(1000, "bye");
}
if (audio != null) {
// Save audio data to local file "output.mp3"
File file = new File("output.mp3");
try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(audio.array());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// The first text transmission requires establishing a WebSocket connection, so the first packet latency includes the connection setup time
System.out.println(
"[Metric] requestId: "
+ synthesizer.getLastRequestId()
+ ", first packet latency (ms): "
+ synthesizer.getFirstPackageDelay());
}
}
import com.alibaba.dashscope.audio.tts.SpeechSynthesisResult;
import com.alibaba.dashscope.audio.ttsv2.SpeechSynthesisAudioFormat;
import com.alibaba.dashscope.audio.ttsv2.SpeechSynthesisParam;
import com.alibaba.dashscope.audio.ttsv2.SpeechSynthesizer;
import com.alibaba.dashscope.common.ResultCallback;
import com.alibaba.dashscope.utils.Constants;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
/**
* SSML feature description:
* 1. Only non-streaming calls and unidirectional streaming calls support the SSML feature
* Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
*/
public class Main {
private static String model = "cosyvoice-v3-flash";
private static String voice = "longanyang";
public static void main(String[] args) {
// Singapore region URL. Replace WorkspaceId with your actual workspace ID. The URL varies by region.
Constants.baseWebsocketApiUrl = "wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference";
streamAudioDataToSpeaker();
System.out.println("Audio has been saved to the output.mp3 file");
System.exit(0);
}
public static void streamAudioDataToSpeaker() {
CountDownLatch latch = new CountDownLatch(1);
final FileOutputStream[] fileOutputStream = new FileOutputStream[1];
try {
fileOutputStream[0] = new FileOutputStream("output.mp3");
} catch (IOException e) {
System.err.println("Failed to create output file: " + e.getMessage());
return;
}
// Implement the ResultCallback interface
ResultCallback<SpeechSynthesisResult> callback = new ResultCallback<SpeechSynthesisResult>() {
@Override
public void onEvent(SpeechSynthesisResult result) {
if (result.getAudioFrame() != null) {
// Write audio data to local file
try {
byte[] audioData = result.getAudioFrame().array();
fileOutputStream[0].write(audioData);
fileOutputStream[0].flush();
} catch (IOException e) {
System.err.println("Failed to write audio data: " + e.getMessage());
}
}
}
@Override
public void onComplete() {
System.out.println("Received Complete, speech synthesis finished");
closeFileOutputStream(fileOutputStream[0]);
latch.countDown();
}
@Override
public void onError(Exception e) {
System.out.println("An error occurred: " + e.toString());
closeFileOutputStream(fileOutputStream[0]);
latch.countDown();
}
};
SpeechSynthesisParam param =
SpeechSynthesisParam.builder()
// The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured an environment variable, replace the following line with your Model Studio API Key: .apiKey("sk-xxx")
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.model(model)
.voice(voice)
.format(SpeechSynthesisAudioFormat.MP3_22050HZ_MONO_256KBPS)
.build();
SpeechSynthesizer synthesizer = new SpeechSynthesizer(param, callback);
try {
// Unidirectional streaming call, returns null immediately (actual results are delivered asynchronously via the callback interface), retrieve binary audio in real time from the onEvent method of the callback interface
// Special characters need to be escaped
synthesizer.call("<speak rate=\"2\">My speaking rate is faster than a normal person's.</speak>");
// Wait for synthesis to complete
latch.await();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
// Close the WebSocket connection after the task ends
try {
synthesizer.getDuplexApi().close(1000, "bye");
} catch (Exception e) {
System.err.println("Failed to close WebSocket connection: " + e.getMessage());
}
// Ensure the file stream is closed
closeFileOutputStream(fileOutputStream[0]);
}
// The first text transmission requires establishing a WebSocket connection, so the first packet latency includes the connection setup time
System.out.println(
"[Metric] requestId: "
+ synthesizer.getLastRequestId()
+ ", first packet latency (ms): "
+ synthesizer.getFirstPackageDelay());
}
private static void closeFileOutputStream(FileOutputStream fileOutputStream) {
try {
if (fileOutputStream != null) {
fileOutputStream.close();
}
} catch (IOException e) {
System.err.println("Failed to close file stream: " + e.getMessage());
}
}
}
SDK Python
# coding=utf-8
# SSML feature description:
# 1. Only non-streaming calls and unidirectional streaming calls support the SSML feature
# Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
import os
import dashscope
# The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
# If you have not configured an environment variable, replace the following line with your Model Studio API Key: api_key="sk-xxx"
# The following is the configuration for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
client = dashscope.Client(
api_key=os.environ.get('DASHSCOPE_API_KEY'),
workspace="{WorkspaceId}",
region="ap-southeast-1",
)
# Model
model = "cosyvoice-v3-flash"
# Voice
voice = "longanyang"
# Non-streaming call, blocks until the audio is returned
# Special characters need to be escaped
audio = client.audio.tts.synthesize(
"<speak rate=\"2\">My speaking rate is faster than a normal person's.</speak>",
model=model,
voice=voice,
enable_ssml=True)
# Save the audio to a local file
with open('output.mp3', 'wb') as f:
f.write(audio)
# coding=utf-8
# SSML feature description:
# 1. Only non-streaming calls and unidirectional streaming calls support the SSML feature
# Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
import os
from datetime import datetime
import dashscope
def get_timestamp():
now = datetime.now()
formatted_timestamp = now.strftime("[%Y-%m-%d %H:%M:%S.%f]")
return formatted_timestamp
# The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
# If you have not configured an environment variable, replace the following line with your Model Studio API Key: api_key="sk-xxx"
# The following is the configuration for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
client = dashscope.Client(
api_key=os.environ.get('DASHSCOPE_API_KEY'),
workspace="{WorkspaceId}",
region="ap-southeast-1",
)
# Model
model = "cosyvoice-v3-flash"
# Voice
voice = "longanyang"
# Unidirectional streaming call, send the text for synthesis and retrieve binary audio chunks in real time
# Special characters need to be escaped
with open("output.mp3", "wb") as f:
for chunk in client.audio.tts.stream(
"<speak rate=\"2\">My speaking rate is faster than a normal person's.</speak>",
model=model,
voice=voice,
enable_ssml=True):
print(get_timestamp() + " Binary audio length: " + str(len(chunk)))
# Write the audio data to file
f.write(chunk)
print("Speech synthesis completed, all results have been received: " + get_timestamp())
API WebSocket
Java
Pour le développement Java, utilisez le SDK DashScope Java. Pour plus de détails, consultez SDK Java.
Cet exemple WebSocket Java nécessite les dépendances suivantes :
Java-WebSocketjackson-databind
Gérez ces dépendances avec Maven ou Gradle :
<dependencies>
<!-- WebSocket Client -->
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.3</version>
</dependency>
<!-- JSON Processing -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version>
</dependency>
</dependencies>
dependencies {
// WebSocket Client
implementation 'org.java-websocket:Java-WebSocket:1.5.3'
// JSON Processing
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
}
Code Java :
import com.fasterxml.jackson.databind.ObjectMapper;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.*;
/**
* SSML feature description:
* 1. When sending the run-task command, set the enable_ssml parameter to true to enable SSML support
* 2. Send text containing SSML via the continue-task command, and only one continue-task command is allowed
* Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
*/
public class TTSWebSocketClient extends WebSocketClient {
private final String taskId = UUID.randomUUID().toString();
private final String outputFile = "output_" + System.currentTimeMillis() + ".mp3";
private boolean taskFinished = false;
public TTSWebSocketClient(URI serverUri, Map<String, String> headers) {
super(serverUri, headers);
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
System.out.println("Connection established");
// Send run-task command
// If enable_ssml is set to true, only one continue-task command is allowed; otherwise the error "Text request limit violated, expected 1." will be returned
String runTaskCommand = "{ \"header\": { \"action\": \"run-task\", \"task_id\": \"" + taskId + "\", \"streaming\": \"duplex\" }, \"payload\": { \"task_group\": \"audio\", \"task\": \"tts\", \"function\": \"SpeechSynthesizer\", \"model\": \"cosyvoice-v3-flash\", \"parameters\": { \"text_type\": \"PlainText\", \"voice\": \"longanyang\", \"format\": \"mp3\", \"sample_rate\": 22050, \"volume\": 50, \"rate\": 1, \"pitch\": 1, \"enable_ssml\": true }, \"input\": {} }}";
send(runTaskCommand);
}
@Override
public void onMessage(String message) {
System.out.println("Received message from server: " + message);
try {
// Parse JSON message
Map<String, Object> messageMap = new ObjectMapper().readValue(message, Map.class);
if (messageMap.containsKey("header")) {
Map<String, Object> header = (Map<String, Object>) messageMap.get("header");
if (header.containsKey("event")) {
String event = (String) header.get("event");
if ("task-started".equals(event)) {
System.out.println("Received task-started event from server");
// Send continue-task command. When using SSML, this command can only be sent once
// Special characters need to be escaped
sendContinueTask("<speak rate=\\\"2\\\">My speaking rate is faster than a normal person's.</speak>");
// Send finish-task command
sendFinishTask();
} else if ("task-finished".equals(event)) {
System.out.println("Received task-finished event from server");
taskFinished = true;
closeConnection();
} else if ("task-failed".equals(event)) {
System.out.println("Task failed: " + message);
closeConnection();
}
}
}
} catch (Exception e) {
System.err.println("An error occurred: " + e.getMessage());
}
}
@Override
public void onMessage(ByteBuffer message) {
System.out.println("Received binary audio data, size: " + message.remaining());
try (FileOutputStream fos = new FileOutputStream(outputFile, true)) {
byte[] buffer = new byte[message.remaining()];
message.get(buffer);
fos.write(buffer);
System.out.println("Audio data written to local file " + outputFile);
} catch (IOException e) {
System.err.println("Failed to write audio data to local file: " + e.getMessage());
}
}
@Override
public void onClose(int code, String reason, boolean remote) {
System.out.println("Connection closed: " + reason + " (" + code + ")");
}
@Override
public void onError(Exception ex) {
System.err.println("Error: " + ex.getMessage());
ex.printStackTrace();
}
private void sendContinueTask(String text) {
String command = "{ \"header\": { \"action\": \"continue-task\", \"task_id\": \"" + taskId + "\", \"streaming\": \"duplex\" }, \"payload\": { \"input\": { \"text\": \"" + text + "\" } }}";
send(command);
}
private void sendFinishTask() {
String command = "{ \"header\": { \"action\": \"finish-task\", \"task_id\": \"" + taskId + "\", \"streaming\": \"duplex\" }, \"payload\": { \"input\": {} }}";
send(command);
}
private void closeConnection() {
if (!isClosed()) {
close();
}
}
public static void main(String[] args) {
try {
// The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured an environment variable, replace the following line with your Model Studio API Key: String apiKey = "sk-xxx"
String apiKey = System.getenv("DASHSCOPE_API_KEY");
if (apiKey == null || apiKey.isEmpty()) {
System.err.println("Please set the DASHSCOPE_API_KEY environment variable");
return;
}
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "bearer " + apiKey);
// Singapore region URL. Replace WorkspaceId with your actual workspace ID. The URL varies by region.
TTSWebSocketClient client = new TTSWebSocketClient(new URI("wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference/"), headers);
client.connect();
while (!client.isClosed() && !client.taskFinished) {
Thread.sleep(1000);
}
} catch (Exception e) {
System.err.println("Failed to connect to WebSocket service: " + e.getMessage());
e.printStackTrace();
}
}
}
Python
Pour le développement en Python, utilisez le SDK DashScope pour Python. Pour plus d'informations, consultez SDK Python.
L'exemple suivant illustre l'utilisation de WebSocket avec Python. Avant de l'exécuter, installez la dépendance requise :
pip uninstall websocket-client
pip uninstall websocket
pip install websocket-client
ImportantLe fichier Python de l’exemple ne doit pas être nommé websocket.py, car ce nom provoque un conflit de noms entraînant une erreur (AttributeError: module 'websocket' has no attribute 'WebSocketApp'. Did you mean: 'WebSocket'?).
# SSML feature description:
# 1. When sending the run-task command, set the enable_ssml parameter to true to enable SSML support
# 2. Send text containing SSML via the continue-task command, and only one continue-task command is allowed
# Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
import websocket
import json
import uuid
import os
import time
class TTSClient:
def __init__(self, api_key, uri):
"""
Initialize a TTSClient instance
Parameters:
api_key (str): API Key for authentication
uri (str): WebSocket service address
"""
self.api_key = api_key # Replace with your API Key
self.uri = uri # Replace with your WebSocket address
self.task_id = str(uuid.uuid4()) # Generate a unique task ID
self.output_file = f"output_{int(time.time())}.mp3" # Output audio file path
self.ws = None # WebSocketApp instance
self.task_started = False # Whether task-started has been received
self.task_finished = False # Whether task-finished / task-failed has been received
def on_open(self, ws):
"""
Callback when WebSocket connection is established
Sends run-task command to start the speech synthesis task
"""
print("WebSocket connected")
# Construct run-task command
run_task_cmd = {
"header": {
"action": "run-task",
"task_id": self.task_id,
"streaming": "duplex"
},
"payload": {
"task_group": "audio",
"task": "tts",
"function": "SpeechSynthesizer",
"model": "cosyvoice-v3-flash",
"parameters": {
"text_type": "PlainText",
"voice": "longanyang",
"format": "mp3",
"sample_rate": 22050,
"volume": 50,
"rate": 1,
"pitch": 1,
# If enable_ssml is set to True, only one continue-task command is allowed; otherwise the error "Text request limit violated, expected 1." will be returned
"enable_ssml": True
},
"input": {}
}
}
# Send run-task command
ws.send(json.dumps(run_task_cmd))
print("run-task command sent")
def on_message(self, ws, message):
"""
Callback when a message is received
Handles text and binary messages separately
"""
if isinstance(message, str):
# Process JSON text messages
try:
msg_json = json.loads(message)
print(f"Received JSON message: {msg_json}")
if "header" in msg_json:
header = msg_json["header"]
if "event" in header:
event = header["event"]
if event == "task-started":
print("Task started")
self.task_started = True
# Send continue-task command. When using SSML, this command can only be sent once
# Special characters need to be escaped
self.send_continue_task("<speak rate=\"2\">My speaking rate is faster than a normal person's.</speak>")
# Send finish-task after continue-task is sent
self.send_finish_task()
elif event == "task-finished":
print("Task completed")
self.task_finished = True
self.close(ws)
elif event == "task-failed":
error_msg = msg_json.get("error_message", "Unknown error")
print(f"Task failed: {error_msg}")
self.task_finished = True
self.close(ws)
except json.JSONDecodeError as e:
print(f"JSON parsing failed: {e}")
else:
# Process binary messages (audio data)
print(f"Received binary message, size: {len(message)} bytes")
with open(self.output_file, "ab") as f:
f.write(message)
print(f"Audio data written to local file {self.output_file}")
def on_error(self, ws, error):
"""Callback when an error occurs"""
print(f"WebSocket error: {error}")
def on_close(self, ws, close_status_code, close_msg):
"""Callback when connection is closed"""
print(f"WebSocket closed: {close_msg} ({close_status_code})")
def send_continue_task(self, text):
"""Send continue-task command with the text content to synthesize"""
cmd = {
"header": {
"action": "continue-task",
"task_id": self.task_id,
"streaming": "duplex"
},
"payload": {
"input": {
"text": text
}
}
}
self.ws.send(json.dumps(cmd))
print(f"continue-task command sent, text content: {text}")
def send_finish_task(self):
"""Send finish-task command to end the speech synthesis task"""
cmd = {
"header": {
"action": "finish-task",
"task_id": self.task_id,
"streaming": "duplex"
},
"payload": {
"input": {}
}
}
self.ws.send(json.dumps(cmd))
print("finish-task command sent")
def close(self, ws):
"""Actively close the connection"""
if ws and ws.sock and ws.sock.connected:
ws.close()
print("Connection closed actively")
def run(self):
"""Start the WebSocket client"""
# Set request headers (authentication)
header = {
"Authorization": f"bearer {self.api_key}",
"X-DashScope-DataInspection": "enable"
}
# Create WebSocketApp instance
self.ws = websocket.WebSocketApp(
self.uri,
header=header,
on_open=self.on_open,
on_message=self.on_message,
on_error=self.on_error,
on_close=self.on_close
)
print("Listening for WebSocket messages...")
self.ws.run_forever() # Start persistent connection listener
# Example usage
if __name__ == "__main__":
# The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
# If you have not configured an environment variable, replace the following line with your Model Studio API Key: API_KEY = "sk-xxx"
API_KEY = os.environ.get("DASHSCOPE_API_KEY")
# Singapore region URL. Replace WorkspaceId with your actual workspace ID. The URL varies by region.
SERVER_URI = "wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference/"
client = TTSClient(API_KEY, SERVER_URI)
client.run()
Go
// SSML feature description:
// 1. When sending the run-task command, set the enable_ssml parameter to true to enable SSML support
// 2. Send text containing SSML via the continue-task command, and only one continue-task command is allowed
// Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"strings"
"time"
"github.com/google/uuid"
"github.com/gorilla/websocket"
)
const (
// Singapore region URL. Replace WorkspaceId with your actual workspace ID. The URL varies by region.
wsURL = "wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference/"
outputFile = "output.mp3"
)
func main() {
// The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured an environment variable, replace the following line with your Model Studio API Key: apiKey := "sk-xxx"
apiKey := os.Getenv("DASHSCOPE_API_KEY")
// Clear the output file
os.Remove(outputFile)
os.Create(outputFile)
// Connect to WebSocket
header := make(http.Header)
header.Add("X-DashScope-DataInspection", "enable")
header.Add("Authorization", fmt.Sprintf("bearer %s", apiKey))
conn, resp, err := websocket.DefaultDialer.Dial(wsURL, header)
if err != nil {
if resp != nil {
fmt.Printf("Connection failed, HTTP status code: %d\n", resp.StatusCode)
}
fmt.Println("Connection failed:", err)
return
}
defer conn.Close()
// Generate task ID
taskID := uuid.New().String()
fmt.Printf("Generated task ID: %s\n", taskID)
// Send run-task command
runTaskCmd := map[string]interface{}{
"header": map[string]interface{}{
"action": "run-task",
"task_id": taskID,
"streaming": "duplex",
},
"payload": map[string]interface{}{
"task_group": "audio",
"task": "tts",
"function": "SpeechSynthesizer",
"model": "cosyvoice-v3-flash",
"parameters": map[string]interface{}{
"text_type": "PlainText",
"voice": "longanyang",
"format": "mp3",
"sample_rate": 22050,
"volume": 50,
"rate": 1,
"pitch": 1,
// If enable_ssml is set to true, only one continue-task command is allowed; otherwise the error "Text request limit violated, expected 1." will be returned
"enable_ssml": true,
},
"input": map[string]interface{}{},
},
}
runTaskJSON, _ := json.Marshal(runTaskCmd)
fmt.Printf("Sending run-task command: %s\n", string(runTaskJSON))
err = conn.WriteMessage(websocket.TextMessage, runTaskJSON)
if err != nil {
fmt.Println("Failed to send run-task:", err)
return
}
textSent := false
// Process messages
for {
messageType, message, err := conn.ReadMessage()
if err != nil {
fmt.Println("Failed to read message:", err)
break
}
// Process binary messages
if messageType == websocket.BinaryMessage {
fmt.Printf("Received binary message, length: %d\n", len(message))
file, _ := os.OpenFile(outputFile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
file.Write(message)
file.Close()
continue
}
// Process text messages
messageStr := string(message)
fmt.Printf("Received text message: %s\n", strings.ReplaceAll(messageStr, "\n", ""))
// Simple JSON parsing to get event type
var msgMap map[string]interface{}
if json.Unmarshal(message, &msgMap) == nil {
if header, ok := msgMap["header"].(map[string]interface{}); ok {
if event, ok := header["event"].(string); ok {
fmt.Printf("Event type: %s\n", event)
switch event {
case "task-started":
fmt.Println("=== Received task-started event ===")
if !textSent {
// Send continue-task command. When using SSML, this command can only be sent once
continueTaskCmd := map[string]interface{}{
"header": map[string]interface{}{
"action": "continue-task",
"task_id": taskID,
"streaming": "duplex",
},
"payload": map[string]interface{}{
"input": map[string]interface{}{
// Special characters need to be escaped
"text": "<speak rate=\"2\">My speaking rate is faster than a normal person's.</speak>",
},
},
}
continueTaskJSON, _ := json.Marshal(continueTaskCmd)
fmt.Printf("Sending continue-task command: %s\n", string(continueTaskJSON))
err = conn.WriteMessage(websocket.TextMessage, continueTaskJSON)
if err != nil {
fmt.Println("Failed to send continue-task:", err)
return
}
textSent = true
// Delay before sending finish-task
time.Sleep(500 * time.Millisecond)
// Send finish-task command
finishTaskCmd := map[string]interface{}{
"header": map[string]interface{}{
"action": "finish-task",
"task_id": taskID,
"streaming": "duplex",
},
"payload": map[string]interface{}{
"input": map[string]interface{}{},
},
}
finishTaskJSON, _ := json.Marshal(finishTaskCmd)
fmt.Printf("Sending finish-task command: %s\n", string(finishTaskJSON))
err = conn.WriteMessage(websocket.TextMessage, finishTaskJSON)
if err != nil {
fmt.Println("Failed to send finish-task:", err)
return
}
}
case "task-finished":
fmt.Println("=== Task completed ===")
return
case "task-failed":
fmt.Println("=== Task failed ===")
if header["error_message"] != nil {
fmt.Printf("Error message: %s\n", header["error_message"])
}
return
case "result-generated":
fmt.Println("Received result-generated event")
}
}
}
}
}
}
C#
using System.Net.WebSockets;
using System.Text;
using System.Text.Json;
// SSML feature description:
// 1. When sending the run-task command, set the enable_ssml parameter to true to enable SSML support
// 2. Send text containing SSML via the continue-task command, and only one continue-task command is allowed
// Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
class Program {
// The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured an environment variable, replace the following line with your Model Studio API Key: private static readonly string ApiKey = "sk-xxx"
private static readonly string ApiKey = Environment.GetEnvironmentVariable("DASHSCOPE_API_KEY") ?? throw new InvalidOperationException("DASHSCOPE_API_KEY environment variable is not set.");
// Singapore region URL. Replace WorkspaceId with your actual workspace ID. The URL varies by region.
private const string WebSocketUrl = "wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference/";
// Output file path
private const string OutputFilePath = "output.mp3";
// WebSocket client
private static ClientWebSocket _webSocket = new ClientWebSocket();
// Cancellation token source
private static CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
// Task ID
private static string? _taskId;
// Whether the task has started
private static TaskCompletionSource<bool> _taskStartedTcs = new TaskCompletionSource<bool>();
static async Task Main(string[] args) {
try {
// Clear the output file
ClearOutputFile(OutputFilePath);
// Connect to the WebSocket service
await ConnectToWebSocketAsync(WebSocketUrl);
// Start the message receiving task
Task receiveTask = ReceiveMessagesAsync();
// Send run-task command
_taskId = GenerateTaskId();
await SendRunTaskCommandAsync(_taskId);
// Wait for the task-started event
await _taskStartedTcs.Task;
// Send continue-task command. When using SSML, this command can only be sent once
// Special characters need to be escaped
await SendContinueTaskCommandAsync("<speak rate=\"2\">My speaking rate is faster than a normal person's.</speak>");
// Send finish-task command
await SendFinishTaskCommandAsync(_taskId);
// Wait for the receiving task to complete
await receiveTask;
Console.WriteLine("Task completed, connection closed.");
} catch (OperationCanceledException) {
Console.WriteLine("Task was cancelled.");
} catch (Exception ex) {
Console.WriteLine($"An error occurred: {ex.Message}");
} finally {
_cancellationTokenSource.Cancel();
_webSocket.Dispose();
}
}
private static void ClearOutputFile(string filePath) {
if (File.Exists(filePath)) {
File.WriteAllText(filePath, string.Empty);
Console.WriteLine("Output file cleared.");
} else {
Console.WriteLine("Output file does not exist, no need to clear.");
}
}
private static async Task ConnectToWebSocketAsync(string url) {
var uri = new Uri(url);
if (_webSocket.State == WebSocketState.Connecting || _webSocket.State == WebSocketState.Open) {
return;
}
// Set WebSocket connection headers
_webSocket.Options.SetRequestHeader("Authorization", $"bearer {ApiKey}");
_webSocket.Options.SetRequestHeader("X-DashScope-DataInspection", "enable");
try {
await _webSocket.ConnectAsync(uri, _cancellationTokenSource.Token);
Console.WriteLine("Successfully connected to the WebSocket service.");
} catch (OperationCanceledException) {
Console.WriteLine("WebSocket connection was cancelled.");
} catch (Exception ex) {
Console.WriteLine($"WebSocket connection failed: {ex.Message}");
throw;
}
}
private static async Task SendRunTaskCommandAsync(string taskId) {
var command = CreateCommand("run-task", taskId, "duplex", new {
task_group = "audio",
task = "tts",
function = "SpeechSynthesizer",
model = "cosyvoice-v3-flash",
parameters = new
{
text_type = "PlainText",
voice = "longanyang",
format = "mp3",
sample_rate = 22050,
volume = 50,
rate = 1,
pitch = 1,
// If enable_ssml is set to true, only one continue-task command is allowed; otherwise the error "Text request limit violated, expected 1." will be returned
enable_ssml = true
},
input = new { }
});
await SendJsonMessageAsync(command);
Console.WriteLine("run-task command sent.");
}
private static async Task SendContinueTaskCommandAsync(string text) {
if (_taskId == null) {
throw new InvalidOperationException("Task ID is not initialized.");
}
var command = CreateCommand("continue-task", _taskId, "duplex", new {
input = new {
text
}
});
await SendJsonMessageAsync(command);
Console.WriteLine("continue-task command sent.");
}
private static async Task SendFinishTaskCommandAsync(string taskId) {
var command = CreateCommand("finish-task", taskId, "duplex", new {
input = new { }
});
await SendJsonMessageAsync(command);
Console.WriteLine("finish-task command sent.");
}
private static async Task SendJsonMessageAsync(string message) {
var buffer = Encoding.UTF8.GetBytes(message);
try {
await _webSocket.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Text, true, _cancellationTokenSource.Token);
} catch (OperationCanceledException) {
Console.WriteLine("Message sending was cancelled.");
}
}
private static async Task ReceiveMessagesAsync() {
while (_webSocket.State == WebSocketState.Open) {
var response = await ReceiveMessageAsync();
if (response != null) {
var eventStr = response.RootElement.GetProperty("header").GetProperty("event").GetString();
switch (eventStr) {
case "task-started":
Console.WriteLine("Task started.");
_taskStartedTcs.TrySetResult(true);
break;
case "task-finished":
Console.WriteLine("Task finished.");
_cancellationTokenSource.Cancel();
break;
case "task-failed":
Console.WriteLine("Task failed: " + response.RootElement.GetProperty("header").GetProperty("error_message").GetString());
_cancellationTokenSource.Cancel();
break;
default:
// result-generated can be handled here
break;
}
}
}
}
private static async Task<JsonDocument?> ReceiveMessageAsync() {
var buffer = new byte[1024 * 4];
var segment = new ArraySegment<byte>(buffer);
try {
WebSocketReceiveResult result = await _webSocket.ReceiveAsync(segment, _cancellationTokenSource.Token);
if (result.MessageType == WebSocketMessageType.Close) {
await _webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", _cancellationTokenSource.Token);
return null;
}
if (result.MessageType == WebSocketMessageType.Binary) {
// Process binary data
Console.WriteLine("Received binary data...");
// Save binary data to file
using (var fileStream = new FileStream(OutputFilePath, FileMode.Append)) {
fileStream.Write(buffer, 0, result.Count);
}
return null;
}
string message = Encoding.UTF8.GetString(buffer, 0, result.Count);
return JsonDocument.Parse(message);
} catch (OperationCanceledException) {
Console.WriteLine("Message receiving was cancelled.");
return null;
}
}
private static string GenerateTaskId() {
return Guid.NewGuid().ToString("N").Substring(0, 32);
}
private static string CreateCommand(string action, string taskId, string streaming, object payload) {
var command = new {
header = new {
action,
task_id = taskId,
streaming
},
payload
};
return JsonSerializer.Serialize(command);
}
}
PHP
La structure du répertoire de code exemple est la suivante :
my-php-project/
├── composer.json
├── vendor/
└── index.php
Le fichier composer.json contient les dépendances suivantes. Ajustez les numéros de version selon vos besoins :
{
"require": {
"react/event-loop": "^1.3",
"react/socket": "^1.11",
"react/stream": "^1.2",
"react/http": "^1.1",
"ratchet/pawl": "^0.4"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
}
}
Le fichier index.php contient le code suivant :
<!-- SSML feature description: -->
<!-- 1. When sending the run-task command, set the enable_ssml parameter to true to enable SSML support -->
<!-- 2. Send text containing SSML via the continue-task command, and only one continue-task command is allowed -->
<!-- 3. Only cloned voices of the qwen-audio-3.0-tts-flash, qwen-audio-3.0-tts-plus, cosyvoice-v3-flash, cosyvoice-v3-plus, and cosyvoice-v2 models, as well as system voices marked as SSML-supported in the voice list, support the SSML feature (for example, the longanyang voice of the cosyvoice-v3-flash model) -->
<?php
require __DIR__ . '/vendor/autoload.php';
use Ratchet\Client\Connector;
use React\EventLoop\Loop;
use React\Socket\Connector as SocketConnector;
// The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured an environment variable, replace the following line with your Model Studio API Key: $api_key = "sk-xxx"
$api_key = getenv("DASHSCOPE_API_KEY");
// Singapore region URL. Replace WorkspaceId with your actual workspace ID. The URL varies by region.
$websocket_url = 'wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference/'; // WebSocket server address
$output_file = 'output.mp3'; // Output file path
$loop = Loop::get();
if (file_exists($output_file)) {
// Clear file contents
file_put_contents($output_file, '');
}
// Create a custom connector
$socketConnector = new SocketConnector($loop, [
'tcp' => [
'bindto' => '0.0.0.0:0',
],
'tls' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
$connector = new Connector($loop, $socketConnector);
$headers = [
'Authorization' => 'bearer ' . $api_key,
'X-DashScope-DataInspection' => 'enable'
];
$connector($websocket_url, [], $headers)->then(function ($conn) use ($loop, $output_file) {
echo "Connected to WebSocket server\n";
// Generate task ID
$taskId = generateTaskId();
// Send run-task command
sendRunTaskMessage($conn, $taskId);
// Define the function to send continue-task command
$sendContinueTask = function() use ($conn, $loop, $taskId) {
// Send continue-task command. When using SSML, this command can only be sent once
$continueTaskMessage = json_encode([
"header" => [
"action" => "continue-task",
"task_id" => $taskId,
"streaming" => "duplex"
],
"payload" => [
"input" => [
// Special characters need to be escaped
"text" => "<speak rate=\"2\">My speaking rate is faster than a normal person's.</speak>"
]
]
]);
$conn->send($continueTaskMessage);
// Send finish-task command
sendFinishTaskMessage($conn, $taskId);
};
// Flag for whether task-started event has been received
$taskStarted = false;
// Listen for messages
$conn->on('message', function($msg) use ($conn, $sendContinueTask, $loop, &$taskStarted, $taskId, $output_file) {
if ($msg->isBinary()) {
// Write binary data to local file
file_put_contents($output_file, $msg->getPayload(), FILE_APPEND);
} else {
// Process non-binary messages
$response = json_decode($msg, true);
if (isset($response['header']['event'])) {
handleEvent($conn, $response, $sendContinueTask, $loop, $taskId, $taskStarted);
} else {
echo "Unknown message format\n";
}
}
});
// Listen for connection close
$conn->on('close', function($code = null, $reason = null) {
echo "Connection closed\n";
if ($code !== null) {
echo "Close code: " . $code . "\n";
}
if ($reason !== null) {
echo "Close reason: " . $reason . "\n";
}
});
}, function ($e) {
echo "Unable to connect: {$e->getMessage()}\n";
});
$loop->run();
/**
* Generate task ID
* @return string
*/
function generateTaskId(): string {
return bin2hex(random_bytes(16));
}
/**
* Send run-task command
* @param $conn
* @param $taskId
*/
function sendRunTaskMessage($conn, $taskId) {
$runTaskMessage = json_encode([
"header" => [
"action" => "run-task",
"task_id" => $taskId,
"streaming" => "duplex"
],
"payload" => [
"task_group" => "audio",
"task" => "tts",
"function" => "SpeechSynthesizer",
"model" => "cosyvoice-v3-flash",
"parameters" => [
"text_type" => "PlainText",
"voice" => "longanyang",
"format" => "mp3",
"sample_rate" => 22050,
"volume" => 50,
"rate" => 1,
"pitch" => 1,
// If enable_ssml is set to true, only one continue-task command is allowed; otherwise the error "Text request limit violated, expected 1." will be returned
"enable_ssml" => true
],
"input" => (object) []
]
]);
echo "Preparing to send run-task command: " . $runTaskMessage . "\n";
$conn->send($runTaskMessage);
echo "run-task command sent\n";
}
/**
* Read audio file
* @param string $filePath
* @return bool|string
*/
function readAudioFile(string $filePath) {
$voiceData = file_get_contents($filePath);
if ($voiceData === false) {
echo "Unable to read audio file\n";
}
return $voiceData;
}
/**
* Split audio data
* @param string $data
* @param int $chunkSize
* @return array
*/
function splitAudioData(string $data, int $chunkSize): array {
return str_split($data, $chunkSize);
}
/**
* Send finish-task command
* @param $conn
* @param $taskId
*/
function sendFinishTaskMessage($conn, $taskId) {
$finishTaskMessage = json_encode([
"header" => [
"action" => "finish-task",
"task_id" => $taskId,
"streaming" => "duplex"
],
"payload" => [
"input" => (object) []
]
]);
echo "Preparing to send finish-task command: " . $finishTaskMessage . "\n";
$conn->send($finishTaskMessage);
echo "finish-task command sent\n";
}
/**
* Handle events
* @param $conn
* @param $response
* @param $sendContinueTask
* @param $loop
* @param $taskId
* @param $taskStarted
*/
function handleEvent($conn, $response, $sendContinueTask, $loop, $taskId, &$taskStarted) {
switch ($response['header']['event']) {
case 'task-started':
echo "Task started, sending continue-task command...\n";
$taskStarted = true;
// Send continue-task command
$sendContinueTask();
break;
case 'result-generated':
// Ignore result-generated events
break;
case 'task-finished':
echo "Task completed\n";
$conn->close();
break;
case 'task-failed':
echo "Task failed\n";
echo "Error code: " . $response['header']['error_code'] . "\n";
echo "Error message: " . $response['header']['error_message'] . "\n";
$conn->close();
break;
case 'error':
echo "Error: " . $response['payload']['message'] . "\n";
break;
default:
echo "Unknown event: " . $response['header']['event'] . "\n";
break;
}
// If the task is completed, close the connection
if ($response['header']['event'] == 'task-finished') {
// Wait 1 second to ensure all data has been transmitted
$loop->addTimer(1, function() use ($conn) {
$conn->close();
echo "Client closed connection\n";
});
}
// If task-started event has not been received, close the connection
if (!$taskStarted && in_array($response['header']['event'], ['task-failed', 'error'])) {
$conn->close();
}
}
Node.js
Installez les dépendances requises :
npm install ws
npm install uuid
Code exemple :
// SSML feature description:
// 1. When sending the run-task command, set the enable_ssml parameter to true to enable SSML support
// 2. Send text containing SSML via the continue-task command, and only one continue-task command is allowed
// Use an SSML-compatible cloned or preset voice (such as longanyang for cosyvoice-v3-flash). See this page for supported models.
import fs from 'fs';
import WebSocket from 'ws';
import { v4 as uuid } from 'uuid'; // For generating UUIDs
// The API Keys for the Singapore and Beijing regions are different. Get an API Key: https://www.alibabacloud.com/help/model-studio/get-api-key
// If you have not configured an environment variable, replace the following line with your Model Studio API Key: const apiKey = "sk-xxx"
const apiKey = process.env.DASHSCOPE_API_KEY;
// Singapore region URL. Replace WorkspaceId with your actual workspace ID. The URL varies by region.
const url = 'wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference/';
// Output file path
const outputFilePath = 'output.mp3';
// Clear the output file
fs.writeFileSync(outputFilePath, '');
// Create WebSocket client
const ws = new WebSocket(url, {
headers: {
Authorization: `bearer ${apiKey}`,
'X-DashScope-DataInspection': 'enable'
}
});
let taskStarted = false;
let taskId = uuid();
ws.on('open', () => {
console.log('Connected to WebSocket server');
// Send run-task command
const runTaskMessage = JSON.stringify({
header: {
action: 'run-task',
task_id: taskId,
streaming: 'duplex'
},
payload: {
task_group: 'audio',
task: 'tts',
function: 'SpeechSynthesizer',
model: 'cosyvoice-v3-flash',
parameters: {
text_type: 'PlainText',
voice: 'longanyang', // Voice
format: 'mp3', // Audio format
sample_rate: 22050, // Sample rate
volume: 50, // Volume
rate: 1, // Speech rate
pitch: 1, // Pitch
enable_ssml: true // Whether to enable SSML. If enable_ssml is set to true, only one continue-task command is allowed; otherwise the error "Text request limit violated, expected 1." will be returned
},
input: {}
}
});
ws.send(runTaskMessage);
console.log('run-task message sent');
});
const fileStream = fs.createWriteStream(outputFilePath, { flags: 'a' });
ws.on('message', (data, isBinary) => {
if (isBinary) {
// Write binary data to file
fileStream.write(data);
} else {
const message = JSON.parse(data);
switch (message.header.event) {
case 'task-started':
taskStarted = true;
console.log('Task started');
// Send continue-task command
sendContinueTasks(ws);
break;
case 'task-finished':
console.log('Task completed');
ws.close();
fileStream.end(() => {
console.log('File stream closed');
});
break;
case 'task-failed':
console.error('Task failed:', message.header.error_message);
ws.close();
fileStream.end(() => {
console.log('File stream closed');
});
break;
default:
// result-generated can be handled here
break;
}
}
});
function sendContinueTasks(ws) {
if (taskStarted) {
// Send continue-task command. When using SSML, this command can only be sent once
const continueTaskMessage = JSON.stringify({
header: {
action: 'continue-task',
task_id: taskId,
streaming: 'duplex'
},
payload: {
input: {
// Special characters need to be escaped
text: '<speak rate="2">I am speaking faster than usual.</speak>'
}
}
});
ws.send(continueTaskMessage);
// Send finish-task command
const finishTaskMessage = JSON.stringify({
header: {
action: 'finish-task',
task_id: taskId,
streaming: 'duplex'
},
payload: {
input: {}
}
});
ws.send(finishTaskMessage);
}
}
ws.on('close', () => {
console.log('Disconnected from WebSocket server');
});
LaTeX
Utilisation
Encadrez les formules mathématiques par des délimiteurs, puis appelez l’API de synthèse vocale.
Délimiteurs pris en charge (choisissez-en un ; l’effet est identique) :
$...$$$...$$\(...\)\[...\]
Exemple d’entrée :
这是一道分数:$\frac{1}{2}$。
La fraction est lue en chinois « 二分之一 » (un demi).
Utilisez les mêmes délimiteurs pour les formules contenant plusieurs opérateurs, par exemple :
这是一道一元二次方程的求根公式:$x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$,请仔细计算。
Dans JSON et les chaînes ordinaires de langages tels que Python, Java et JavaScript, écrivez la barre oblique inverse \ sous la forme \\. Par exemple, écrivez la commande LaTeX \frac sous la forme \\frac dans une chaîne ordinaire.
Démarrage rapide
Cet exemple Python synthétise un texte chinois contenant une fraction et l’enregistre dans output.mp3. Consultez le démarrage rapide SSML pour configurer la clé API et le SDK.
# coding=utf-8
import os
import dashscope
# If you have not configured an environment variable, replace the following line with your Model Studio API Key: api_key="sk-xxx"
# The following is the configuration for the Singapore region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
client = dashscope.Client(
api_key=os.environ.get('DASHSCOPE_API_KEY'),
workspace="{WorkspaceId}",
region="ap-southeast-1",
)
model = "cosyvoice-v3-flash"
voice = "longanyang"
# Escape each backslash as \\ in a regular string.
audio = client.audio.tts.synthesize("这是一道分数:$\\frac{1}{2}$。", model=model, voice=voice)
with open('output.mp3', 'wb') as f:
f.write(audio)
Balises SSML
RemarqueL’implémentation repose sur la spécification W3C SSML 1.0. Seules les balises indiquées ci-dessous sont prises en charge.
<speak>: Élément racine
<speak> constitue l'élément racine de tout contenu SSML. L'intégralité du texte doit figurer entre des balises <speak></speak>.
<speak>Text that requires SSML processing</speak>
Attributs
Attribut | Type | Obligatoire | Description |
|---|---|---|---|
| Chaîne | Non | Définit la voix à utiliser. Cet attribut prévaut sur le paramètre
|
| Chaîne | Non | Détermine la vitesse d'élocution. Cet attribut prévaut sur le paramètre
|
| Chaîne | Non | Ajuste la hauteur de la voix. Cet attribut prévaut sur le paramètre
|
| Chaîne | Non | Règle le volume sonore. Cet attribut prévaut sur le paramètre
|
| Chaîne | Non | Applique un effet audio spécifique.
|
| Chaîne | Non | Configure le comportement précis de l'effet audio (paramètre
|
| Chaîne | Non | Ajoute une musique de fond à la parole synthétisée. Stockez le fichier audio dans Alibaba Cloud OSS et rendez-le accessible par une URL Internet. Consultez Charger des objets. Un objet privé peut utiliser une URL signée valide. Échappez les caractères XML spéciaux de l’URL, par exemple en remplaçant
ImportantLa personne qui téléverse le fichier audio assume la responsabilité juridique relative aux droits d’auteur de ce fichier. |
| Chaîne | Non | Définit le volume de la musique de fond. Cet attribut s'utilise conjointement avec l'attribut |
Exemples
Sans attribut
<speak>
Text that requires SSML tags
</speak>
Attributs combinés, séparés par des espaces
<speak rate="1.5" pitch="0.8" volume="80">
So when put together, my voice sounds like this.
</speak>
voice
<speak voice="longcheng_v2">
I am a male voice.
</speak>
rate
<speak rate="2">
My speech rate is faster than normal.
</speak>
pitch
<speak pitch="0.5">
However, my pitch is lower than others.
</speak>
volume
<speak volume="80">
My volume is also very high.
</speak>
effect
<speak effect="robot">
Do you like the robot WALL-E?
</speak>
effectValue
<speak effect="eq" effectValue="1 -20 1 1 1 1 20 1">
Do you like the robot WALL-E?
</speak>
<speak effect="lpfilter" effectValue="1200">
Do you like the robot WALL-E?
</speak>
<speak effect="hpfilter" effectValue="1200">
Do you like the robot WALL-E?
</speak>
bgm
<speak bgm="https://nls.alicdn.com/bgm/2.wav" backgroundMusicVolume="30" rate="0.8" volume="40">
<break time="2s"/>
The old trees on the shady cliff are shrouded in mist
<break time="700ms"/>
The sound of rain is still in the bamboo forest
<break time="700ms"/>
I know that cotton contributes to the country's plan
<break time="700ms"/>
The scenery of Mianzhou is always pitiable
<break time="2s"/>
</speak>
Relations entre balises
La balise <speak> peut contenir du texte ainsi que les balises enfants suivantes :
<break>: Contrôler la durée des pauses<sub>: Remplacer du texte<phoneme>: Préciser la prononciation (pinyin ou phonétique)<soundEvent>: Insérer un son externe (sonnerie, miaulement, etc.)<say-as>: Définir la lecture du texte (nombres, dates, téléphones, etc.)
<break>: Contrôler les pauses
Insère une pause silencieuse lors de la synthèse vocale afin de simuler les pauses naturelles d'une conversation. Les unités de temps acceptées sont les secondes (s) et les millisecondes (ms).
<!-- No attributes -->
<break/>
<!-- With time attribute -->
<break time="string"/>
Attributs
Attribut | Type | Obligatoire | Description |
|---|---|---|---|
| Chaîne | Non | Indique la durée de la pause, en secondes ou en millisecondes (par exemple, « 2s » ou « 50ms »).
Lorsque plusieurs balises Par exemple, dans le code SSML ci-dessous, la durée cumulée des balises |
Sans attribut, <break> insère une pause d’une seconde.
Exemples
time
<speak>
Please close your eyes and take a rest.<break time="500ms"/>Okay, please open your eyes.
</speak>
Les trois balises <break> consécutives ci-dessous définissent une pause totale de 15 secondes. La pause effective est limitée à 10 secondes.
<speak>
Please close your eyes and take a rest.<break time="5s"/><break time="5s"/><break time="5s"/>Okay, please open your eyes.
</speak>
Relations entre balises
<break> est un élément auto-fermant qui ne peut pas contenir d'éléments enfants.
<sub>: Remplacer le texte
Remplace un texte donné par un contenu mieux adapté à la synthèse vocale. Par exemple, « W3C » sera lu comme « World Wide Web Consortium ».
<sub alias="string"></sub>
Attributs
Attribut | Type | Obligatoire | Description |
|---|---|---|---|
| Chaîne | Oui | Définit le texte de remplacement à lire à haute voix. |
Exemples
alias
<speak>
<sub alias="network protocol">W3C</sub>
</speak>
Relations entre balises
La balise <sub> ne peut contenir que du texte brut.
<phoneme>: Spécifier la prononciation
Offre un contrôle précis de la prononciation du texte. Le texte chinois admet la notation pinyin, tandis que le texte anglais prend en charge la notation phonétique CMU. Cette fonctionnalité s'avère particulièrement utile pour lever les ambiguïtés des caractères polyphoniques et gérer la prononciation des langues étrangères.
<phoneme alphabet="string" ph="string">Text</phoneme>
Attributs
Attribut | Type | Obligatoire | Description |
|---|---|---|---|
| Chaîne | Oui | Définit le type de prononciation : pinyin pour le chinois ou symboles phonétiques pour l'anglais. Valeurs autorisées :
|
| Chaîne | Oui | Spécifie la notation pinyin ou phonétique exacte. Règles d'utilisation :
|
Exemples
ph
<speak>
去<phoneme alphabet="py" ph="dian3 dang4 hang2">典当行</phoneme>把这个玩意<phoneme alphabet="py" ph="dang4 diao4">当掉</phoneme>
</speak>
<speak>
How to spell <phoneme alphabet="cmu" ph="S AY N">sin</phoneme>?
</speak>
Relations entre balises
La balise <phoneme> ne peut contenir que du texte brut.
<soundEvent>: Insérer un effet sonore
Insère un fichier d'effet sonore (tel qu'une alerte ou un son d'ambiance) à un endroit précis de la parole afin d'enrichir le rendu audio.
<soundEvent src="URL"/>
Attributs
Attribut | Type | Obligatoire | Description |
|---|---|---|---|
| Chaîne | Oui | Indique l’URL d’un fichier audio externe. Stockez le fichier audio dans Alibaba Cloud OSS et rendez-le accessible par une URL Internet. Consultez Charger des objets. Un objet privé peut utiliser une URL signée valide. Échappez les caractères XML spéciaux de l’URL, par exemple en remplaçant
ImportantLa personne qui téléverse le fichier audio assume la responsabilité juridique relative aux droits d’auteur de ce fichier. |
Exemples
src
<speak>
A horse was frightened<soundEvent src="https://nls.alicdn.com/sound-event/horse-neigh.wav"/>and people scattered to avoid it.
</speak>
Relations entre balises
<soundEvent> est un élément auto-fermant qui ne peut pas contenir d'éléments enfants.
<say-as>: Définir la lecture du texte
Cet élément précise le type de contenu du texte (tel que des nombres, des dates ou des numéros de téléphone) afin que le système le lise selon les règles appropriées à ce type.
<say-as interpret-as="string">Text</say-as>
Attributs
Attribut | Type | Obligatoire | Description |
|---|---|---|---|
| Chaîne | Oui | Définit le type de contenu du texte situé à l'intérieur de la balise. Valeurs autorisées:
|
Afficher les formats say-as pris en charge
cardinal
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Suite de chiffres | 145 | 一百四十五 | Entiers positifs et négatifs de 20 chiffres maximum : [-99999999999999999999,99999999999999999999]. Aucun maximum précis pour les décimales ; 10 ou moins sont recommandées. |
Signe moins+Suite de chiffres | -145 | 负一百四十五 | |
Groupes de 3 chiffres séparés par des virgules | 10,000 | 一万 | |
Signe moins+Groupes de 3 chiffres séparés par des virgules | -10,124 | 负一万一百二十四 | |
Suite de chiffres+Point décimal+Deux zéros | 10.00 | 十 | |
Signe moins+Suite de chiffres+Point décimal+Deux zéros | -110.00 | 负一百一十 | |
Suite de chiffres+Point décimal+Suite de chiffres | 79.090 | 七十九点零九零 | |
Signe moins+Suite de chiffres+Point décimal+Suite de chiffres | -79.001 | 负七十九点零零一 |
Anglais
Format | Exemple | Sortie en anglais | Remarques |
|---|---|---|---|
Chaîne de chiffres | 145 | one hundred forty five | Entiers: entiers positifs et négatifs jusqu'à 13 chiffres, [-999999999999,999999999999]. Décimaux: aucune limite particulière du nombre de décimales ; 10 au maximum sont recommandées. |
Chaîne de chiffres commençant par zéro | 0145 | one hundred forty five | |
Signe moins + chaîne de chiffres | -145 | minus hundred forty five | |
Chaîne de chiffres avec virgule séparant chaque groupe de 3 chiffres | 60,000 | sixty thousand | |
Signe moins + chaîne de chiffres séparés par des virgules | -208,000 | minus two hundred eight thousand | |
Chaîne de chiffres + point décimal + zéro | 12.00 | twelve | |
Chaîne de chiffres + point décimal + chaîne de chiffres | 12.34 | twelve point three four | |
Chaîne de chiffres séparés par des virgules + point décimal + chaîne de chiffres | 1,000.1 | one thousand point one | |
Signe moins + chaîne de chiffres + point décimal + chaîne de chiffres | -12.34 | minus twelve point three four | |
Signe moins + chaîne de chiffres séparés par des virgules + point décimal + chaîne de chiffres | -1,000.1 | minus one thousand point one | |
Chaîne de chiffres (séparés par des virgules) + trait d'union + chaîne de chiffres (séparés par des virgules) | 1-1,000 | one to one thousand | |
Autres lectures par défaut | 012.34 | twelve point three four | Aucune |
1/2 | one half | ||
-3/4 | minus three quarters | ||
5.1/6 | five point one over six | ||
-3 1/2 | minus three and a half | ||
1,000.3^3 | one thousand point three to the power of three | ||
3e9.1 | three times ten to the power of nine point one | ||
23.10% | twenty three point one percent |
digits
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Suite de chiffres | 129090909 | 一二九零九零九零九 | La longueur n’a pas de limite précise ; 20 chiffres ou moins sont recommandés. Au-delà de 10 chiffres, une pause suit chaque chiffre. |
Anglais
Format | Exemple | Sortie en anglais | Remarques |
|---|---|---|---|
Chaîne de chiffres | 12034 | one two zero three four | Aucune limite spécifique sur la longueur de la chaîne de chiffres, mais il est recommandé de ne pas dépasser 20 chiffres. Lorsque les chaînes de chiffres sont regroupées par des espaces ou des traits d'union, une pause marquée par une virgule est insérée entre les groupes. Jusqu'à 5 groupes sont pris en charge. |
Suite de chiffres + espace/tiret + suite de chiffres + espace/tiret + suite de chiffres + espace/tiret + suite de chiffres | 1-23-456 7890 | one, two three, four five six, seven eight nine zero |
telephone
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Numéro fixe | 4930286 | 四九三 零二八六 | Numéros fixes de 7 ou 8 chiffres, séparés par des espaces ou des traits d’union (-). Regroupement 3-4 pour 7 chiffres et 4-4 pour 8 chiffres. |
493 0286 | 四九三 零二八六 | ||
493-0286 | 四九三 零二八六 | ||
62552560 | 六二五五 二五六零 | ||
6255 2560 | 六二五五 二五六零 | ||
6255-2560 | 六二五五 二五六零 | ||
Numéro fixe+Numéro de poste | 4930286-109 | 四九三 零二八六 转幺零九 | Numéros de poste de 1 à 4 chiffres. |
4930286转109 | 四九三 零二八六 转幺零九 | ||
4930286分机109 | 四九三 零二八六 分机幺零九 | ||
4930286分机号109 | 四九三 零二八六 分机号幺零九 | ||
Indicatif régional+Numéro fixe | 01062552560 | 零幺零 六二五五 二五六零 | Indicatifs régionaux : 010, 02x, 03xx, 04xx, 05xx, 07xx, 08xx, 09xx. |
010 62552560 | 零幺零 六二五五 二五六零 | ||
010 6255 2560 | 零幺零 六二五五 二五六零 | ||
010 6255-2560 | 零幺零 六二五五 二五六零 | ||
010-62552560 | 零幺零 六二五五 二五六零 | ||
010-6255-2560 | 零幺零 六二五五 二五六零 | ||
(010)62552560 | 零幺零 六二五五 二五六零 | ||
03198907098 | 零三幺九 八九零 七零九八 | ||
0319-8907098 | 三幺九 八九零 七零九八 | ||
Indicatif régional+Numéro fixe+Numéro de poste | 010 62552560-109 | 零幺零 六二五五 二五六零 转幺零九 | Aucune |
010-62552560-109 | 零幺零 六二五五 二五六零 转幺零九 | ||
(010)62552560-109 | 零幺零 六二五五 二五六零 转幺零九 | ||
(010)62552560转109 | 零幺零 六二五五 二五六零 转幺零九 | ||
(010)62552560分机109 | 零幺零 六二五五 二五六零 分机幺零九 | ||
(010)62552560分机号109 | 零幺零 六二五五 二五六零 分机号幺零九 | ||
Indicatif du pays+Indicatif régional+Numéro fixe | 86-010-62791627 | 八六 零幺零 六二七九 幺六二七 | Les indicatifs 86, (86), +86, (+86) et 0086 sont tous lus « 八六 » (huit six). |
(86)10-62791627 | 八六 幺零 六二七九 幺六二七 | ||
+86-010-62791627 | 八六 零幺零 六二七九 幺六二七 | ||
0086-10-62791627 | 八六 幺零 六二七九 幺六二七 | ||
(+86)-10-6279 1627 | 八六 幺零 六二七九 幺六二七 | ||
Indicatif du pays+Indicatif régional+Numéro fixe+Numéro de poste | (86)21-58118818-207 | 八六 二幺 五八幺幺 八八幺八 转二零七 | Aucune |
(86)021-5811-8818-207 | 八六 零二幺 五八幺幺 八八幺八 转二零七 | ||
(86)021-58118818转207 | 八六 零二幺 五八幺幺 八八幺八 转二零七 | ||
(86)21-5811-8818分机207 | 八六 二幺 五八幺幺 八八幺八 分机二零七 | ||
+86-021-58118818分机号207 | 八六 零二幺 五八幺幺 八八幺八分机号二零七 | ||
Numéro de mobile | 139 0000 5678 | 幺三九 零零零零 五六七八 | Numéros de mobile de 11 chiffres, regroupés en 3-3-5 ou 3-4-4. |
139-000-05678 | 幺三九 零零零 零五六七八 | ||
139 000 05678 | 幺三九 零零零 零五六七八 | ||
Indicatif du pays+Numéro de mobile | +86-13900005678 | 八六 幺三九 零零零零 五六七八 | Aucune |
(+86)-139-0000-5678 | 八六 幺三九 零零零零 五六七八 | ||
+8613900005678 | 八六 幺三九 零零零零 五六七八 | ||
0086-139 000 05678 | 八六 幺三九 零零零 零五六七八 | ||
Numéro de service | 123 | 幺二三 | Numéros de service courants, numéros de 10 chiffres commençant par 400/800 regroupés en 3-3-4, et numéros de 16 chiffres commençant par 12530/17951/12593. |
95678 | 九五六七八 | ||
4008110510 | 四零零 八幺幺 零五幺零 | ||
800-810-8888 | 八零零 八幺零 八八八八 | ||
1253013520638377 | 幺二五三零 幺三五 二零六三 八三七七 | ||
Autre | (86)(21)9899-80800-0909 | 八六 二幺 九八九九 八零八零零 零九零九 | Suites de chiffres avec séparateurs (parenthèses ou traits d’union). |
Anglais
Format | Exemple | Sortie en anglais | Remarques |
|---|---|---|---|
Chaîne de chiffres | 12034 | one two oh three four | Aucune limite spécifique sur la longueur de la chaîne de chiffres, mais il est recommandé de ne pas dépasser 20 chiffres. Lorsque les chaînes de chiffres sont regroupées par des espaces ou des traits d'union, une pause marquée par une virgule est insérée entre les groupes. Jusqu'à 5 groupes sont pris en charge. |
Suite de chiffres + espace/tiret + suite de chiffres + espace/tiret + suite de chiffres | 1-23-456 7890 | one, two three, four five six, seven eight nine oh | |
Signe plus + suite de chiffres + espace/tiret + suite de chiffres | +43-211-0567 | plus four three, two one, oh five six seven | |
Parenthèse ouvrante + suite de chiffres + parenthèse fermante + espace + suite de chiffres + espace/tiret + suite de chiffres | (21) 654-3210 | (two one) six five four, three two one oh |
address
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Format d’adresse courant | 元和镇嘉元30-9 | 元和镇嘉元三十杠九 | Formats d’adresse courants. Il s’agit ici d’adresses postales standard. |
市台路388弄1107-1108号 | 市台路三八八弄幺幺零七杠幺幺零八号 | ||
华润二十四城六期锦云府3-1-3205 | 华润二十四城六期锦云府三杠一杠三二零五 | ||
圣华名都大厦2幢2006室 | 圣华名都大厦二幢二零零六室 | ||
五常街道庭院5幢4单元201 | 五常街道庭院五幢四单元二零幺 | ||
芙蓉江路150弄19号 | 芙蓉江路幺五零弄十九号 |
Anglais
Ce type n’est pas pris en charge pour le texte anglais.
id
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Chaîne | dell0101 | D E L L 零 一 零 一 | Lettres anglaises majuscules et minuscules, chiffres 0-9 et traits de soulignement. Les espaces indiquent des pauses entre les caractères lus un par un. |
myid_1998 | M Y I D 下划线 一 九 九 八 | ||
AiTest | A I T E S T |
Anglais
Pour le texte anglais, ce type fonctionne comme characters.
characters
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Chaîne | ISBN 1-001-099098-1 | I S B N 一 杠 零 零 一 杠 零 九 九 零 九 八 杠 一 | Caractères chinois, lettres anglaises majuscules et minuscules, chiffres 0-9 et certains caractères pleine et demi-chasse. Les espaces indiquent des pauses entre les caractères lus un par un. Échappez les caractères XML spéciaux. |
x10b2345_u | x 一 零 b 二 三 四 五 下划线 u | ||
v1.0.1 | v 一 点 零 点 一 | ||
版本号2.0 | 版本号二 点 零 | ||
苏M MA000 | 苏M M A 零 零 零 | ||
空中客车A330 | 空中客车A 三 三 零 | ||
型号s01 s02和s03 | 型号s 零 一 s 零二 和s 零 三 | ||
空中客车A330 | 空中客车A 三 三 零 | ||
αβγ | 阿尔法 贝塔 伽玛 |
Anglais
Format | Exemple | Sortie en anglais | Remarques |
|---|---|---|---|
Chaîne | *b+3$.c-0'=α | asterisk B plus three dollar dot C dash zero apostrophe equals alpha | Prend en charge les caractères chinois, les lettres majuscules et minuscules, les chiffres de 0 à 9, ainsi que certains caractères pleine chasse et demi-chasse. Les espaces dans la sortie indiquent des pauses entre les caractères, ce qui signifie que chaque caractère est lu individuellement. Si le texte à l'intérieur de la balise contient des caractères spéciaux XML, échappez-les. |
punctuation
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Ponctuation | … | 省略号 | Ponctuation courante chinoise et anglaise. Les espaces indiquent des pauses entre les caractères lus un par un. Échappez les caractères XML spéciaux. |
…… | 省略号 | ||
!"#$%& | 叹号 双引号 井号 dollar 百分号 and | ||
‘()*+ | 单引号 左括号 右括号 星号 加号 | ||
,-./:; | 逗号 杠 点 斜杠 冒号 分号 | ||
<=>?@ | 小于 等号 大于 问号 at | ||
[\]^_ | 左方括号 反斜线 右方括号 脱字符 下划线 |
Anglais
Pour le texte anglais, ce type fonctionne comme characters.
date
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
xx年 | 71年 | 七一年 | Années à 2 chiffres : 60-99, 00-09 et 10-19. Années à 4 chiffres : 1000-1999 et 2000-2099. |
04年 | 零四年 | ||
19年 | 一九年 | ||
1011年 | 一零一一年 | ||
1998年 | 一九九八年 | ||
2008年 | 二零零八年 | ||
xx年xx月 | 98年4月 | 九八年四月 | Les mois 1-9 peuvent inclure ou omettre le zéro initial, par exemple « 1908年4月 » et « 1908年04月 ». |
1998年04月 | 一九九八年四月 | ||
08年8月 | 零八年八月 | ||
2008年8月 | 二零零八年八月 | ||
xx年xx月xx日xx年xx月xx号 | 98年4月23日 | 九八年四月二十三日 | Les jours 1-9 peuvent inclure ou omettre le zéro initial, par exemple « 1908年4月8日 » et « 1908年04月08日 ». |
1998年04月23日 | 一九九八年四月二十三日 | ||
08年8月8号 | 零八年八月八号 | ||
2008年08月08号 | 二零零八年八月八号 | ||
xx年xx月xx日xx年xx月xx号 | 98年4月23日 | 九八年四月二十三日 | Les jours 1-9 peuvent inclure ou omettre le zéro initial, par exemple « 1908年4月8日 » et « 1908年04月08日 ». |
1998年04月23日 | 一九九八年四月二十三日 | ||
08年8月8号 | 零八年八月八号 | ||
2008年08月08号 | 二零零八年八月八号 | ||
xx月xx号 | 3月20日 | 三月二十日 | Aucune |
08月07号 | 八月七号 | ||
Abréviation année/mois | 2018/08 | 二零一八年八月 | Séparateurs acceptés : /, - et . |
2018-08 | 二零一八年八月 | ||
2018.08 | 二零一八年八月 | ||
Abréviation année/mois/jour | 2018/08/08 | 二零一八年八月八日 | |
2018-8-8 | 二零一八年八月八日 | ||
2018.08.08 | 二零一八年八月八日 | ||
xx年xx月xx日~xx年xx月xx日xx年xx月xx号~xx年xx月xx号 | 04年9月1日~30日 | 零四年九月一日至三十日 | Les signes ~ et - indiquent « à ». |
2004年09月01号-2008年06月08号 | 二零零四年九月一号至二零零八年六月八号 | ||
xx年xx月xx日~xx日xx年xx月xx号~xx号 | 04年9月1日~30日 | 零四年九月一日至三十日 | |
2004年09月01号-2008年06月08号 | 二零零四年九月一号至二零零八年六月八号 | ||
xx年xx月~xx年xx月 | 01年04月~10年04月 | 零一年四月至一零年四月 | |
2001年04月~2010年04月 | 二零零一年四月至二零一零年四月 | ||
xx月xx日~xx月xx日xx月xx号~xx月xx号 | 10月1日~10月7日 | 十月一日至十月七日 | |
10月01号~10月07号 | 十月一号至十月七号 | ||
xx月xx日~xx日xx月xx号~xx号 | 10月1日~7日 | 十月一日至七日 | |
10月01号~07号 | 十月一号至七号 | ||
Abréviation année/mois/jour~Abréviation année/mois/jour | 2018/03/03~2019/01/01 | 二零一八年三月三日至二零一九年一月一日 | Séparateurs : / et . ; ~ et - indiquent « à ». |
1997.9.9~1998.9.9 | 一九九七年九月九日至一九九八年九月九日 | ||
Abréviation mois/jour~Abréviation mois/jour | 10/20~10/31 | 十月二十日至十月三十一日 | |
xx~xx月xx月~xx月 | 1~10月 | 一至十月 | |
1月~10月 | 一月至十月 | ||
Abréviation mois/jour/année | 10/20/2018 | 二零一八年十月二十日 | Années à 4 chiffres, séparateurs / et ordre mois/jour/année uniquement. |
Anglais
Format | Exemple | Sortie en anglais | Remarques |
|---|---|---|---|
Quatre chiffres/deux chiffres ou quatre chiffres-deux chiffres | 2000/01 | two thousand, oh one | S'étend sur plusieurs années. |
1900-01 | nineteen hundred, oh one | ||
2001-02 | twenty oh one, oh two | ||
2019-20 | twenty nineteen, twenty | ||
1998-99 | nineteen ninety eight, ninety nine | ||
1999-00 | nineteen ninety nine, oh oh | ||
Nombre à quatre chiffres commençant par 1 ou 2 | 2000 | two thousand | Année à 4 chiffres. |
1900 | nineteen hundred | ||
1905 | nineteen oh five | ||
2021 | twenty one | ||
Jour - jour de la semaine (trait d'union) ou Jour - jour de la semaine ou Jour & jour de la semaine | mon-wed | monday to wednesday | Si le texte dans la balise de plage de jours de la semaine contient des caractères spéciaux XML, échappez ces caractères. |
tue~fri | tuesday to friday | ||
sat&sun | saturday and sunday | ||
DD-DD MMM, YYYY ou DD~DD MMM, YYYY ou DD&DD MMM, YYYY | 19-20 Jan, 2000 | the nineteen to the twentieth of january two thousand | DD: jour sur 2 chiffres. MMM: mois abrégé sur 3 lettres ou en toutes lettres. YYYY: année sur 4 chiffres commençant par 1 ou 2. |
01 ~ 10 Jul, 2020 | the first to the tenth of july twenty | ||
05&06 Apr, 2009 | the fifth and the sixth of april two thousand nine | ||
MMM DD-DD ou MMM DD~DD ou MMM DD&DD | Feb 01 - 03 | feburary the first to the third | MMM: mois abrégé sur 3 lettres ou en toutes lettres. DD: jour sur 2 chiffres. |
Aug 10~20 | august the tenth to the twentieth | ||
Dec 11&12 | december the eleventh and the twelfth | ||
MMM-MMM ou MMM~MMM ou MMM&MMM | Jan-Jun | january to june | MMM: mois abrégé sur 3 lettres ou en toutes lettres. |
jul ~ dec | july to december | ||
sep&oct | september and october | ||
YYYY-YYYY ou YYYY~YYYY | 1990 - 2000 | nineteen ninety to two thousand | YYYY: année sur 4 chiffres commençant par 1 ou 2. |
2001~2021 | two thousand one to twenty one | ||
WWW DD MMM YYYY | Sun 20 Nov 2011 | sunday the twentieth of november twenty eleven | WWW est l'abréviation sur trois lettres ou le nom complet du jour de la semaine. DD est le jour sur deux chiffres. MMM est le mois abrégé sur trois lettres ou en toutes lettres. MM est le mois sur deux chiffres, abrégé sur trois lettres ou en toutes lettres. YYYY est l'année sur quatre chiffres commençant par 1 ou 2. |
WWW DD MMM | Sun 20 Nov | sunday the twentieth of november | |
WWW MMM DD YYYY | Sun Nov 20 2011 | sunday november the twentieth twenty eleven | |
WWW MMM DD | Sun Nov 20 | sunday november the twentieth | |
WWW YYYY-MM-DD | Sat 2010-10-01 | aturday october the first twenty ten | |
WWW YYYY/MM/DD | Sat 2010/10/01 | saturday october the first twenty ten | |
WWW MM/DD/YYYY | Sun 11/20/2011 | sunday november the twentieth twenty eleven | |
MM/DD/YYYY | 11/20/2011 | november the twentieth twenty eleven | |
YYYY | 1998 | nineteen ninety eight | |
Autres lectures par défaut | 10 Mar, 2001 | the tenth of march two thousand one | Aucune |
10 Mar | the tenth of march | ||
Mar 2001 | march two thousand one | ||
Fri. 10/Mar/2001 | friday the tenth of march two thousand one | ||
Mar 10th, 2001 | march the tenth two thousand one | ||
Mar 10 | march the tenth | ||
2001/03/10 | march the tenth two thousand one | ||
2001-03-10 | march the tenth two thousand one | ||
2000s | two thousands | ||
2010's | twenty tens | ||
1900's | nineteen hundreds | ||
1990s | nineteen nineties |
time
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Heure | 12:00 | 十二点 | Formats d’heure et de plage horaire courants. |
12:00:00点 | 十二点 | ||
10:20分 | 十点二十分 | ||
10:20:30 | 十点二十分三十秒 | ||
09:18:14 | 九点十八分十四秒 | ||
Heure~Heure | 11:00~12:00 | 十一点到十二点 | |
09:00-14:00 | 九点到十四点 | ||
11:00~11:30 | 十一点到十一点三十分 | ||
11:00-12:18 | 十一点到十二点十八分 | ||
10:30~11:00 | 十点三十分到十一点 | ||
09:28-10:00 | 九点二十八分到十点 | ||
10:20~11:20 | 十点二十分到十一点二十分 | ||
06:00~08:00 | 六点到八点 | ||
上午10:20~下午13:30 | 上午十点二十分到下午十三点三十分 | ||
Abréviation d’heure | 5:00 am | 凌晨五点整 | |
5:30 am | 凌晨五点半 | ||
5:20:12 am | 凌晨五点二十分十二秒 | ||
7:00 am | 上午七点整 | ||
7:30 AM | 上午七点半 | ||
7:20:12 a.m. | 上午七点二十分十二秒 | ||
07:08:12 A.M. | 上午七点零八分十二秒 | ||
5:00 pm | 下午五点整 | ||
5:30 PM | 下午五点半 | ||
5:20:12 p.m. | 下午五点二十分十二秒 | ||
05:09:12 P.M. | 下午五点零九分十二秒 | ||
9:00 pm | 晚上九点整 | ||
9:30 pm | 晚上九点半 | ||
9:20:12 PM | 晚上九点二十分十二秒 | ||
9:02:12 P.M. | 晚上九点零二分十二秒 | ||
12:00 pm | 中午十二点整 | ||
12:30 p.m. | 中午十二点半 | ||
12:20:12 PM | 中午十二点二十分十二秒 |
Anglais
Format | Exemple | Sortie en anglais | Remarques |
|---|---|---|---|
HH:MM AM ou PM | 09:00 AM | nine A M | HH: heure sur 1 ou 2 chiffres. MM: minutes sur 2 chiffres. AM/PM: matin/après-midi. |
09:03 PM | nine oh three P M | ||
09:13 p.m. | nine thirteen p m | ||
HH:MM | 21:00 | twenty one hundred | |
HHMM | 100 | one oclock | |
Point horaire-Point horaire | 8:00 am - 05:30 pm | eight a m to five p m | Prend en charge les formats et plages horaires courants. |
7:05~10:15 AM | seven oh five to ten fifteen A M | ||
09:00-13:00 | nine oclock to thirteen hundred |
currency
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Nombre+Identifiant de devise | 12.00 RMB | 十二人民币 | AUD (dollar australien), CAD (dollar canadien), HKD (dollar de Hong Kong), JPY (yen), USD (dollar américain), CHF (franc suisse), NOK (couronne norvégienne), SEK (couronne suédoise), GBP (livre sterling), RMB (renminbi), CNY (yuan) et EUR (euro). Entiers, décimaux et notation internationale avec séparateurs virgules. |
12.50 RMB | 十二点五零人民币 | ||
12,000,000 RMB | 一千二百万人民币 | ||
12,000,000.00 RMB | 一千二百万人民币 | ||
12,000.35 RMB | 一万两千点三五人民币 | ||
Identifiant de devise+Nombre | $12 | 十二美元 | CAD (dollar canadien), $ (dollar américain), Fr (franc), kr (couronne danoise), £ (livre sterling), ¥ (yuan) et € (euro). Entiers, décimaux et notation internationale avec séparateurs virgules. |
$12.00 | 十二美元 | ||
$12.12 | 二点一二美元 | ||
$12,000 | 一万两千美元 | ||
$12,000.00 | 一万两千美元 | ||
$12,000.99 | 一万两千点九九美元 | ||
Autres lectures par défaut | 1213 | 一千二百一十三 | Aucune |
1213 KML | 一千二百一十三K M L | ||
1213.00 KML | 一千二百一十三K M L | ||
1213.9 KML | 一千二百一十三点九K M L | ||
1,000 KML | 一千K M L | ||
1,000.00 KML | 一千K M L | ||
1,000.98 KML | 一千点九八K M L | ||
12,000 | 一万两千 |
Anglais
Format | Exemple | Sortie en anglais | Remarques |
|---|---|---|---|
Nombre + identifiant de devise | 1.00 RMB | one yuan | Formats numériques pris en charge: entiers, décimaux et notation internationale avec virgules de séparation. Identifiants monétaires pris en charge: CN¥ (yuan) CNY (yuan) RMB (yuan) AUD (dollar australien) CAD (dollar canadien) CHF (franc suisse) DKK (couronne danoise) EUR (euro) GBP (livre sterling) HKD (dollar de Hong Kong (Chine)) JPY (yen japonais) NOK (couronne norvégienne) SEK (couronne suédoise) SGD (dollar de Singapour) USD (dollar des États-Unis) |
2.02 CNY | two point zero two yuan | ||
1,000.23 CN¥ | one thousand point two three yuan | ||
1.01 SGD | one singapore dollar and one cent | ||
2.01 CAD | two canadian dollars and one cent | ||
3.1 HKD | three hong kong dollars and ten cents | ||
1,000.00 EUR | one thousand euros | ||
Identifiant de devise + nombre | US$ 1.00 | one US dollar | Formats numériques pris en charge: entiers, décimaux et notation internationale avec virgules de séparation. Identifiants monétaires pris en charge: US$ (dollar américain) CA$ (dollar canadien) AU$ (dollar australien) SG$ (dollar de Singapour) HK$ (dollar de Hong Kong) C$ (dollar canadien) A$ (dollar australien) $ (dollar) £ (livre) € (euro) CN¥ (yuan) CNY (yuan) RMB (yuan) AUD (dollar australien) CAD (dollar canadien) CHF (franc suisse) DKK (couronne danoise) EUR (euro) GBP (livre sterling) HKD (dollar de Hong Kong (Chine)) JPY (yen japonais) NOK (couronne norvégienne) SEK (couronne suédoise) SGD (dollar de Singapour) USD (dollar des États-Unis) |
$0.01 | one cent | ||
JPY 1.01 | one japanese yen and one sen | ||
£1.1 | one pound and ten pence | ||
€2.01 | two euros and one cent | ||
USD 1,000 | one thousand united states dollars | ||
Nombre + classificateur + identifiant de devise ou Identifiant de devise + nombre + quantificateur | 1.23 Tn RMB | one point two three trillion yuan | Formats de multiplicateurs pris en charge: thousand million billion trillion Mil (million) mil (million) Bil (billion) bil (billion) MM (million) Bn (billion) bn (billion) Tn (trillion) tn (trillion) K (thousand) k (thousand) M (million) m (million) |
$1.2 K | one point two thousand dollars |
measure
Chinois
Format | Exemple | Sortie en chinois | Remarques |
|---|---|---|---|
Nombre+Unité chinoise | 2片 | 两片 | Unités chinoises courantes et abréviations d’unités. |
120公顷 | 一百二十公顷 | ||
100多毫克 | 一百多毫克 | ||
100来米 | 一百来米 | ||
100余人 | 一百余人 | ||
1厘米20毫米 | 一厘米二十毫米 | ||
120.00平方公里 | 一百二十平方公里 | ||
Nombre+Abréviation d’unité | 120.56 cm² | 一百二十点五六平方厘米 | |
120 ㎡ 56 cm² | 一百二十平方米五十六平方厘米 | ||
100 m 12 cm 6 mm | 一百米十二厘米六毫米 | ||
Plage | 10~15 kg | 十至十五千克 | |
10.24~789.82亩 | 十点二四至七百八十九点八二亩 | ||
10米~15米 | 十米至十五米 | ||
10.24 cm~19.08 cm | 十点二四厘米至十九点零八厘米 | ||
Nombre+Unité+"/"+Unité | 10元/斤 | 十元每斤 | |
199~299元/件 | 一百九十九至二百九十九元每件 | ||
299.99元/g~399.99元/g | 二百九十九点九九元每克至三百九十九点九九元每克 | ||
Autres lectures par défaut | 12扎 | 十二扎 | |
30 rm | 三十r m | ||
4万万同胞 | 四万万同胞 | ||
12.897微克 | 十二点八九七微克 |
Anglais
Format | Exemple | Sortie en anglais | Remarques |
|---|---|---|---|
Nombre + unité de mesure | 1.0 kg | one kilogram | Formats numériques pris en charge: entiers, décimaux et notation internationale avec virgules de séparation. Prend en charge les abréviations d'unités courantes. |
1,234.01 km | one thousand two hundred thirty four point zero one kilometres. | ||
Unité de mesure | mm2 | square millimetre |
Symboles courants
Symbole | Lecture chinoise | Lecture anglaise |
|---|---|---|
! | 叹号 | exclamation mark |
“ | 双引号 | double quote |
# | 井号 | pound |
$ | dollar | dollar |
% | 百分号 | percent |
& | and | and |
‘ | 单引号 | left quote |
( | 左括号 | left parenthesis |
) | 右括号 | right parenthesis |
* | 星 | asterisk |
+ | 加 | plus |
, | 逗号 | comma |
- | 杠 | dash |
. | 点 | dot |
/ | 斜杠 | slash |
: | 零冒号 | solon |
; | 分号 | semicolon |
< | 小于 | less than |
= | 等号 | equals |
> | 大于 | greater than |
? | 问号 | question mark |
@ | at | at |
[ | 左方括号 | left bracket |
\ | 反斜线 | back slash |
] | 右方括号 | right bracket |
^ | 脱字符 | caret |
_ | 下划线 | underscore |
` | 反引号 | back quote |
{ | 左花括号 | left brace |
| | 竖线 | vertical bar |
} | 右花括号 | right brace |
~ | 波浪线 | tilde |
! | 叹号 | exclamation mark |
“ | 左双引号 | left double quote |
” | 右双引号 | right double qute |
‘ | 左单引号 | left quote |
’ | 右单引号 | right quote |
( | 左括号 | left parenthesis |
) | 右括号 | right parenthesis |
, | 逗号 | comma |
。 | 句号 | full stop |
— | 杠 | em dash |
: | 冒号 | colon |
; | 分号 | semicolon |
? | 问号 | question mark |
、 | 顿号 | enumeration comma |
… | 省略号 | ellipsis |
…… | 省略号 | ellipsis |
《 | 左书名号 | left guillemet |
》 | 右书名号 | right guillemet |
¥ | 人民币符号 | yuan |
≥ | 大于等于 | greater than or equal to |
≤ | 小于等于 | less than or equal to |
≠ | 不等于 | not equal |
≈ | 约等于 | approximately equal |
± | 加减 | plus or minus |
× | 乘 | times |
π | 派 | pi |
Α | 阿尔法 | alpha |
Β | 贝塔 | beta |
Γ | 伽玛 | gamma |
Δ | 德尔塔 | delta |
Ε | 艾普西龙 | epsilon |
Ζ | 捷塔 | zeta |
Θ | 西塔 | theta |
Ι | 艾欧塔 | iota |
Κ | 喀帕 | kappa |
∧ | 拉姆达 | lambda |
Μ | 缪 | mu |
Ν | 拗 | nu |
Ξ | 克西 | ksi |
Ο | 欧麦克轮 | omicron |
∏ | 派 | pi |
Ρ | 柔 | rho |
∑ | 西格玛 | sigma |
Τ | 套 | tau |
Υ | 宇普西龙 | upsilon |
Φ | fai | phi |
Χ | 器 | chi |
Ψ | 普赛 | psi |
Ω | 欧米伽 | omega |
α | 阿尔法 | alpha |
β | 贝塔 | beta |
γ | 伽玛 | gamma |
δ | 德尔塔 | delta |
ε | 艾普西龙 | epsilon |
ζ | 捷塔 | zeta |
η | 依塔 | eta |
θ | 西塔 | theta |
ι | 艾欧塔 | iota |
κ | 喀帕 | kappa |
λ | 拉姆达 | lambda |
μ | 缪 | mu |
ν | 拗 | nu |
ξ | 克西 | ksi |
ο | 欧麦克轮 | omicron |
π | 派 | pi |
ρ | 柔 | rho |
σ | 西格玛 | sigma |
τ | 套 | tau |
υ | 宇普西龙 | upsilon |
φ | fai | phi |
χ | 器 | chi |
ψ | 普赛 | psi |
ω | 欧米伽 | omega |
Unités courantes
Format | Catégorie | Exemples chinois | Exemples anglais |
|---|---|---|---|
Abréviation | Longueur | nm(纳米)、μm(微米)、 mm(毫米)、cm(厘米)、m(米)、km(千米)、ft(英尺)、in(英寸) | nm (nanometre), μm (micrometre), mm (millimetre), cm (centimetre), m (metre), km (kilometre), ft (foot), in (inch) |
Surface | cm²(平方厘米)、㎡(平方米)、km²(平方千米)、SqFt(平方英尺) | cm² (square centimetre), ㎡ (square metre), km2 (square kilometre), SqFt (square foot) | |
Volume | cm³(立方厘米)、m³(立方米)、km³(立方千米)、mL(毫升)、L(升)、gallon(加仑) | cm³ (cubic centimetre), m³ (cubic metre), km3 (cubic kilometre), mL (millilitre), L (millilitre), gal (gallon) | |
Poids | μg(微克)、mg(毫克)、g(克)、kg(千克) | μg (microgram), mg (microgram), g (gram), kg (kilogram) | |
Temps | min(分)、sec(秒)、ms(毫秒) | min (minute), sec (second), ms (millisecond) | |
Électromagnétisme | μA(微安)、mA(毫安)、Ω(欧姆)、Hz(赫兹)、kHz(千赫兹)、MHz(兆赫兹)、GHz(吉赫兹)、V(伏)、kV(千伏)、kWh(千瓦时) | μA (microamp), mA (milliamp), Hz (hertz), kHz (kilohertz), MHz (megahertz), GHz (gigahertz), V (volt), kV (kilovolt), kWh (kilowatt hour) | |
Son | dB(分贝) | dB (decibel) | |
Pression | Pa(帕)、kPa(千帕)、Mpa(兆帕) | Pa (pascal), kPa (kilopascal), MPa (megapascal) | |
Autres unités courantes | Prend aussi en charge les unités chinoises « 米 », « 秒 », « 美元 » et « 毫升每瓶 », ainsi que les classificateurs chinois « 架 », « 场 », « 头 », « 部 » et « 盆 », entre autres. | Prend aussi en charge d’autres unités, telles que tsp (teaspoon), rpm (round per minute), KB (kilobyte) et mmHg (millimetre of mercury). | |
Exemples
cardinal
<speak>
<say-as interpret-as="cardinal">12345</say-as>
</speak>
<speak>
<say-as interpret-as="cardinal">10234</say-as>
</speak>
digits
<speak>
<say-as interpret-as="digits">12345</say-as>
</speak>
<speak>
<say-as interpret-as="digits">10234</say-as>
</speak>
telephone
<speak>
<say-as interpret-as="telephone">12345</say-as>
</speak>
<speak>
<say-as interpret-as="telephone">10234</say-as>
</speak>
name
<speak>
她的曾用名是<say-as interpret-as="name">曾小凡</say-as>
</speak>
address
<speak>
<say-as interpret-as="address">富路国际1号楼3单元304</say-as>
</speak>
id
<speak>
<say-as interpret-as="id">myid_1998</say-as>
</speak>
characters
<speak>
<say-as interpret-as="characters">希腊字母αβ</say-as>
</speak>
<speak>
<say-as interpret-as="characters">*b+3.c$=α</say-as>
</speak>
punctuation
<speak>
<say-as interpret-as="punctuation"> -./:;</say-as>
</speak>
date
<speak>
<say-as interpret-as="date">1000-10-10</say-as>
</speak>
<speak>
<say-as interpret-as="date">10-01-2020</say-as>
</speak>
time
<speak>
<say-as interpret-as="time">5:00am</say-as>
</speak>
<speak>
<say-as interpret-as="time">0500</say-as>
</speak>
currency
<speak>
<say-as interpret-as="currency">13,000,000.00RMB</say-as>
</speak>
<speak>
<say-as interpret-as="currency">$1,000.01</say-as>
</speak>
measure
<speak>
<say-as interpret-as="measure">100m12cm6mm</say-as>
</speak>
<speak>
<say-as interpret-as="measure">1,000.01kg</say-as>
</speak>
Relations entre balises
La balise <say-as> peut contenir du texte.
Balises et symboles LaTeX
Sélectionnez une catégorie pour consulter les balises et symboles pris en charge. Les exemples d’entrée incluent les délimiteurs. Les lectures restent en chinois, car cette fonction produit de la parole chinoise.
Mathématiques de base
Balise ou symbole | Signification | Exemple de source de formule | Exemple de texte d’entrée | Exemple de lecture |
|---|---|---|---|---|
| Addition |
|
| 二加三等于五 |
| Soustraction |
|
| 三减二等于一 |
| Plus ou moins |
|
| 正负一加减二 |
Positif ou négatif | ||||
| Multiplication |
|
| 二乘三等于六 |
|
|
| ||
|
|
| ||
| Division |
|
| 六除二等于三 |
|
|
| ||
|
|
| ||
| Égal |
|
| 三加五等于八 |
| Inférieur à |
|
| 一小于二 |
| Inférieur ou égal à |
|
| 三小于等于五 |
|
|
| ||
|
|
| ||
|
|
| ||
|
|
| ||
|
|
| ||
| Supérieur à |
|
| 二大于一 |
| Supérieur ou égal à |
|
| 五大于等于三 |
|
|
| ||
|
|
| ||
|
|
| ||
|
|
| ||
|
|
| ||
| Fraction |
|
| 三分之二 |
| Puissance |
|
| 二的一次方 |
| Racine |
|
| 根号下九等于三 |
|
| 三次根号下八等于二 | ||
| Pourcentage |
|
| 百分之五 |
| Valeur absolue |
|
| 绝对值三的绝对值等于三 |
|
|
| 绝对值三绝对值等于三 | |
| Logarithme |
|
| log十 |
| Logarithme |
|
| log五 |
| Logarithme naturel |
|
| LN十 |
| Factorielle |
|
| 五的阶乘 |
| Parenthèses |
|
| 括号内二加一 |
|
| 大括号二加一反大括号 |
Symboles mathématiques spéciaux
Balise ou symbole | Signification | Exemple de source de formule | Exemple de texte d’entrée | Exemple de lecture |
|---|---|---|---|---|
| alpha |
|
| α |
|
|
| ||
| beta |
|
| β |
|
|
| ||
| gamma |
|
| γ |
|
|
| ||
| delta |
|
| Δ |
|
|
| ||
| Infini (chinois) |
|
| 无穷大 |
| infty (anglais) |
|
|
Géométrie
Balise ou symbole | Signification | Exemple de source de formule | Exemple de texte d’entrée | Exemple de lecture |
|---|---|---|---|---|
| Pi |
|
| 派等于三点一四一五九 |
| Fonction trigonométrique |
|
| sine三十度等于二分之一 |
|
|
| cosine四十五度等于二分之根号下二 | |
|
|
| tangent三十度等于cosine三十度分之sine三十度 | |
|
|
| cosecant A | |
|
|
| secant A | |
|
|
| cotangent A | |
| Angle |
|
| 角A B |
|
|
| ||
| Degré |
|
| 角A B 等于三十度 |
| Cercle |
|
| 圆 |
| Arc |
|
| 弧BC |
| Angle droit |
|
| 因为直角三角形ABC |
|
|
| 所以AB垂直于BC | |
| Triangle |
|
| 三角形ABC |
|
|
| ||
| Parallélogramme |
|
| 平行四边形ABCD |
| Perpendiculaire |
|
| A B 垂直于 B C |
|
|
| ||
|
|
| ||
| Parallèle |
|
| A平行于B |
| Parallèle et égal |
|
| A平行且相等于B |
| Congruent |
|
| 三角形ABC全等于三角形DEF |
Conditions
Balise ou symbole | Signification | Exemple de source de formule | Exemple de texte d’entrée | Exemple de lecture |
|---|---|---|---|---|
| Implique |
|
| 推出一加一等于二 |
| Équivalent |
|
| p等价q |
| Parce que |
|
| 因为a等于b所以b等于a |
| Donc |
Unités
Encadrez les unités par \unit, \quantity, \mathit, \mathrm ou \rm, par exemple \unit{cm}.
Balise ou symbole | Signification | Exemple de source de formule | Exemple de texte d’entrée | Exemple de lecture |
|---|---|---|---|---|
| Millimètre |
|
| 五毫米 |
| Centimètre |
|
| 五厘米 |
| Décimètre |
|
| 五分米 |
| Mètre |
|
| 五米 |
| Kilomètre |
|
| 五千米 |
| Gramme |
|
| 五克 |
| Kilogramme |
|
| 五千克 |
| Tonne |
|
| 五吨 |
| Millimètre carré |
|
| 五平方毫米 |
| Centimètre carré |
|
| 五平方厘米 |
| Décimètre carré |
|
| 五平方分米 |
| Mètre carré |
|
| 五平方米 |
| Kilomètre carré |
|
| 五平方千米 |
| Millimètre cube |
|
| 五立方毫米 |
| Centimètre cube |
|
| 五立方厘米 |
| Décimètre cube |
|
| 五立方分米 |
| Mètre cube |
|
| 五立方米 |
| Kilomètre cube |
|
| 五立方千米 |
| Millilitre |
|
| 五毫升 |
| Seconde |
|
| 五秒 |
| Minute |
|
| 五分 |
| Heure |
|
| 五小时 |
| Kilomètres par heure |
|
| 五千米每小时 |
| Grammes par litre |
|
| 五克每升 |
FAQ
Pourquoi une formule n’est-elle pas lue correctement ?
- Vérifiez que la formule est encadrée par
$...$,$$...$$,\(...\)ou\[...\]. - Recherchez les balises ou symboles non pris en charge.
- Vérifiez que chaque
\est échappé sous la forme\\dans la chaîne de requête.
Comment gérer les barres obliques inverses dans le code ?
Consultez les instructions d’échappement dans Utilisation. La source d’une formule et les chaînes du code utilisent des notations différentes : écrivez \frac sous la forme \\frac dans une chaîne ordinaire.