## Basic model info - Model name: microsoft/microsoft mai-voice-2-flash - Model description: MAI Voice 2 Flash is the low-latency variant of Microsoft's text-to-speech model, built for real-time voice agents at a lower price per character. - Endpoint name: text-to-speech ## Model schema The model schema is defined in the OpenAPI schema: [OpenAPI Schema](https://oapi.sunra.ai/main/microsoft/mai-voice-2-flash/latest.json) ### Model input schema The model input schema is: ```json { "properties": { "output_format": { "default": "mp3", "enum": [ "mp3", "wav", "opus" ], "title": "Output Format", "type": "string", "x-sr-order": 404 }, "speed": { "default": 1, "description": "Speaking rate, 1.0 being the voice's natural pace.", "maximum": 2, "minimum": 0.5, "title": "Speed", "type": "number", "x-sr-order": 403 }, "style": { "anyOf": [ { "enum": [ "adventurous", "angry", "caringempathy", "confused", "curious", "determined", "disgusted", "embarrassed", "encouraging", "excited", "fearful", "friendlycheerful", "happy", "hopeful", "jealous", "joyful", "nostalgic", "reflective", "regretful", "relieved", "sad", "saddisappointed", "serious", "shouting", "softvoice", "surprised", "whispering" ], "type": "string" }, { "type": "null" } ], "description": "Speaking style. Support varies by voice — 12 of the 47 voices take no style at all, and the rest each accept a subset.", "title": "Style", "x-sr-order": 402 }, "text": { "description": "Text to speak. Billed per character.", "maxLength": 10000, "minLength": 1, "title": "Text", "type": "string", "x-sr-order": 201 }, "voice": { "default": "en-US-Ethan", "description": "Voice to speak in, named -. Covers 18 locales; a voice can also read text in another supported language.", "enum": [ "de-DE-Klaus", "de-DE-Mia", "en-AU-Isla", "en-US-Ethan", "en-US-Grant", "en-US-Harper", "en-US-Iris", "en-US-Jasper", "en-US-Olivia", "es-ES-Marta", "es-MX-Alejo", "es-MX-Valeria", "fr-FR-Marc", "fr-FR-Soleil", "hi-IN-Arjun", "hi-IN-Dhruv", "hi-IN-Kavya", "hi-IN-Priya", "hu-HU-Bence", "hu-HU-Levente", "hu-HU-Lilla", "hu-HU-Réka", "it-IT-Luca", "it-IT-Rosa", "ko-KR-Haena", "ko-KR-Junho", "nl-NL-Fleur", "nl-NL-Sander", "pt-BR-Caio", "pt-BR-Luana", "pt-BR-Pedro", "pt-BR-Rafael", "pt-PT-Rui", "ro-RO-Andrei", "ro-RO-Elena", "ro-RO-Ioana", "ro-RO-Radu", "ru-RU-Lev", "ru-RU-Masha", "th-TH-Krit", "th-TH-Nattapong", "tr-TR-Aydın", "tr-TR-Elif", "zh-CN-Bo", "zh-CN-Lan", "zh-CN-Mei", "zh-CN-Wei" ], "title": "Voice", "type": "string", "x-sr-order": 401 } }, "required": [ "text" ], "title": "TextToSpeechInput", "type": "object" } ``` ### Model output schema The model output schema is: ```json { "properties": { "audio": { "properties": { "content_type": { "description": "The mime type of the file.", "title": "Content Type", "type": "string" }, "file_name": { "description": "The name of the file. It will be auto-generated if not provided.", "title": "File Name", "type": "string" }, "file_size": { "description": "The size of the file in bytes.", "title": "File Size", "type": "integer" }, "url": { "description": "The URL where the file can be downloaded from.", "title": "Url", "type": "string" } }, "required": [ "content_type", "file_name", "file_size", "url" ], "title": "SunraFile", "type": "object" } }, "required": [ "audio" ], "title": "AudioOutput", "type": "object" } ``` ## Example inputs and outputs Use the following example inputs and outputs to understand the model. ### Input example ```json { "output_format": "mp3", "speed": 1, "style": null, "text": "", "voice": "en-US-Ethan" } ``` ### Output example ```json { } ``` ## Model code examples ### JavaScript ```javascript import { sunra } from "@sunra/client"; const result = await sunra.subscribe("microsoft/mai-voice-2-flash/text-to-speech", { input: { text: '', voice: 'en-US-Ethan', style: null, speed: 1, output_format: 'mp3' }, logs: true, onQueueUpdate: (update) => { console.log(`Status Update: ${update.status}, Request ID: ${update.request_id}`); }, }); console.log(result.data); console.log(result.requestId); ``` ### Python ```python import sunra_client result = sunra_client.subscribe( "microsoft/mai-voice-2-flash/text-to-speech", arguments={ "text": "", "voice": "en-US-Ethan", "style": None, "speed": 1, "output_format": "mp3" }, with_logs=True, on_enqueue=print, on_queue_update=print, ) print(result) ``` ### Java ```java import ai.sunra.client.*; import java.util.Map; import com.google.gson.JsonObject; var client = SunraClient.withEnvCredentials(); var response = client.subscribe( "microsoft/mai-voice-2-flash/text-to-speech", SubscribeOptions.builder() .input(Map.of( "text", "", "voice", "en-US-Ethan", "style", null, "speed", 1, "output_format", "mp3")) .resultType(JsonObject.class) .onQueueUpdate(update -> System.out.printf( "\nStatus Update: %s, Request ID: %s%n", update.getStatus(), update.getRequestId() )) .logs(true) .build() ); System.out.println("Completed!"); System.out.println(response.getData()); ``` ### Kotlin ```kotlin import ai.sunra.client.kt.* import com.google.gson.JsonObject val client = createSunraClient() val response = client.subscribe( endpointId = "microsoft/mai-voice-2-flash/text-to-speech", input = mapOf( "text" to "", "voice" to "en-US-Ethan", "style" to null, "speed" to 1, "output_format" to "mp3"), options = ai.sunra.client.kt.SubscribeOptions(logs = true), onUpdate = { update -> println("\nStatus Update: ${update.status}, Request ID: ${update.requestId}") } ) println("Completed!") println(response.data) ``` ### Curl ```bash curl --request POST \ --url https://api.sunra.ai/v1/queue/microsoft/mai-voice-2-flash/text-to-speech \ --header "Authorization: Key $SUNRA_KEY" \ --header "Content-Type: application/json" \ --data '{"text":"","voice":"en-US-Ethan","style":null,"speed":1,"output_format":"mp3"}' ``` ## Model readme >