Usare l'API di Trascrizione rapida (anteprima) con Voce di Azure AI

Nota

Questa funzionalità è attualmente in anteprima pubblica. Questa anteprima viene messa a disposizione senza contratto di servizio e non è consigliata per i carichi di lavoro di produzione. Alcune funzionalità potrebbero non essere supportate o potrebbero presentare funzionalità limitate. Per altre informazioni, vedere le Condizioni supplementari per l'uso delle anteprime di Microsoft Azure.

L'API di Trascrizione rapida è disponibile solo tramite l'API REST di Riconoscimento vocale, versione 2024-05-15-preview. Questa versione di anteprima è soggetta a modifiche e non è consigliata per l'uso in produzione. Verrà ritirata senza preavviso 90 giorni dopo l’introduzione della versione di anteprima o della disponibilità generale dell'API che la sostituisce.

L'API di Trascrizione rapida viene usata per trascrivere i file audio e ottenere risultati in modo sincrono e molto più veloce rispetto all'audio in tempo reale. Usare Trascrizione rapida negli scenari in cui è necessario trascrivere una registrazione audio il più rapidamente possibile con una latenza prevedibile, ad esempio:

  • Trascrizione rapida di audio o video, sottotitoli e modifica.
  • Traduzione video

Suggerimento

Provare Trascrizione rapida in Studio AI della piattaforma Azure.

Prerequisiti

  • Una risorsa di Voce di Azure AI in una delle aree in cui è disponibile l'API di Trascrizione rapida. Le aree supportate sono: India centrale, Stati Uniti orientali, Asia sud-orientale ed Europa occidentale. Per altre informazioni sulle aree supportate per altre funzionalità del servizio Voce, vedere Aree del servizio Voce.
  • Un file audio (di durata inferiore a 2 ore e di dimensioni inferiori a 200 MB) in uno dei formati e codec supportati dall'API di Trascrizione in batch. Per altre informazioni sui formati audio supportati, vedere Formati audio supportati.

Usare l'API di Trascrizione rapida

L'API di Trascrizione rapida è un'API REST che usa multipart/form-data per inviare file audio per la trascrizione. L'API restituisce i risultati della trascrizione in modo sincrono.

Creare il corpo della richiesta in base alle istruzioni seguenti:

  • Impostare la proprietà locales obbligatoria. Questo valore deve corrispondere alle impostazioni locali previste per i audio da trascrivere. Le impostazioni locali supportate sono: en-US, es-ES, es-MX, fr-FR, hi-IN, it-IT, ja-JP, ko-KR, pt-BR e zh-CN. È possibile specificare una sola impostazione locale per ogni richiesta di trascrizione.
  • Facoltativamente, impostare la proprietà profanityFilterMode per specificare come gestire il contenuto volgare nei risultati del riconoscimento. I valori accettati sono None per disabilitare i filtri del contenuto volgare, Masked per sostituire il contenuto volgare con asterischi, Removed per rimuovere tutto il contenuto volgare dal risultato o Tags per aggiungere i tag per il contenuto volgare. Il valore predefinito è Masked. La proprietà profanityFilterMode funziona allo stesso modo dell'API di Trascrizione in batch.
  • Facoltativamente, impostare la proprietà channels per specificare gli indici in base zero dei canali da trascrivere separatamente. Se non si specifica alcuna impostazione, vengono uniti più canali che vengono trascritti congiuntamente. Sono supportati solo un massimo di due canali. Per trascrivere canali da un file audio stereo separatamente, specificare [0,1] qui. In caso contrario, l'audio stereo verrà unito all’audio mono, l'audio mono verrà lasciato così come è e verrà trascritto solo un singolo canale. In uno dei due casi, l'output non dispone di indici di canale per il testo trascritto in quanto viene trascritto solo un singolo flusso audio.

Inviare una richiesta POST multipart/form-data all'endpoint transcriptions con il file audio, specificando le proprietà del corpo della richiesta. L'esempio seguente mostra come creare una trascrizione con l'API di Trascrizione rapida.

  • Sostituire YourSubscriptionKey con la chiave della risorsa Voce.
  • Sostituire YourServiceRegion con l'area della risorsa Voce.
  • Sostituire YourAudioFile con il percorso del file audio.
  • Impostare le proprietà di definizione del modulo come descritto in precedenza.
curl --location 'https://YourServiceRegion.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=2024-05-15-preview' \
--header 'Content-Type: multipart/form-data' \
--header 'Accept: application/json' \
--header 'Ocp-Apim-Subscription-Key: YourSubscriptionKey' \
--form 'audio=@"YourAudioFile"' \
--form 'definition="{
    \"locales\":[\"en-US\"], 
    \"profanityFilterMode\": \"Masked\", 
    \"channels\": [0,1]}"'

La risposta includerà duration, channel e altro ancora. La proprietà combinedPhrases contiene le trascrizioni complete separate per ogni canale. Ad esempio, tutto ciò che il primo parlante ha detto si trova nel primo elemento della matrice combinedPhrases mentre tutto ciò che ha detto il secondo parlante si trova nel secondo elemento della matrice.

{
	"duration": 185079,
	"combinedPhrases": [
		{
			"channel": 0,
			"text": "Hello. Thank you for calling Contoso. Who am I speaking with today? Hi, Mary. Are you calling because you need health insurance? Great. If you can answer a few questions, we can get you signed up in the Jiffy. So what's your full name? Got it. And what's the best callback number in case we get disconnected? Yep, that'll be fine. Got it. So to confirm, it's 234-554-9312. Excellent. Let's get some additional information for your application. Do you have a job? OK, so then you have a Social Security number as well. OK, and what is your Social Security number please? Sorry, what was that, a 25 or a 225? You cut out for a bit. Alright, thank you so much. And could I have your e-mail address please? Great. Uh That is the last question. So let me take your information and I'll be able to get you signed up right away. Thank you for calling Contoso and I'll be able to get you signed up immediately. One of our agents will call you back in about 24 hours or so to confirm your application. Absolutely. If you need anything else, please give us a call at 1-800-555-5564, extension 123. Thank you very much for calling Contoso. Uh Yes, of course. So the default is a digital membership card, but we can send you a physical card if you prefer. Uh, yeah. Absolutely. I've made a note on your file. You're very welcome. Thank you for calling Contoso and have a great day."
		},
		{
			"channel": 1,
			"text": "Hi, my name is Mary Rondo. I'm trying to enroll myself with Contuso. Yes, yeah, I'm calling to sign up for insurance. Okay. So Mary Beth Rondo, last name is R like Romeo, O like Ocean, N like Nancy D, D like Dog, and O like Ocean again. Rondo. I only have a cell phone so I can give you that. Sure, so it's 234-554 and then 9312. Yep, that's right. Uh Yes, I am self-employed. Yes, I do. Uh Sure, so it's 412256789. It's double two, so 412, then another two, then five. Yeah, it's maryrondo@gmail.com. So my first and last name at gmail.com. No periods, no dashes. That was quick. Thank you. Actually, so I have one more question. I'm curious, will I be getting a physical card as proof of coverage? uh Yes. Could you please mail it to me when it's ready? I'd like to have it shipped to, are you ready for my address? So it's 2660 Unit A on Maple Avenue SE, Lansing, and then zip code is 48823. Awesome. Thanks so much."
		}
	],
	"phrases": [
		{
			"channel": 0,
			"offset": 720,
			"duration": 480,
			"text": "Hello.",
			"words": [
				{
					"text": "Hello.",
					"offset": 720,
					"duration": 480
				}
			],
			"locale": "en-US",
			"confidence": 0.9177142
		},
		{
			"channel": 0,
			"offset": 1200,
			"duration": 1120,
			"text": "Thank you for calling Contoso.",
			"words": [
				{
					"text": "Thank",
					"offset": 1200,
					"duration": 200
				},
				{
					"text": "you",
					"offset": 1400,
					"duration": 80
				},
				{
					"text": "for",
					"offset": 1480,
					"duration": 120
				},
				{
					"text": "calling",
					"offset": 1600,
					"duration": 240
				},
				{
					"text": "Contoso.",
					"offset": 1840,
					"duration": 480
				}
			],
			"locale": "en-US",
			"confidence": 0.9177142
		},
		{
			"channel": 0,
			"offset": 2320,
			"duration": 1120,
			"text": "Who am I speaking with today?",
			"words": [
				{
					"text": "Who",
					"offset": 2320,
					"duration": 160
				},
				{
					"text": "am",
					"offset": 2480,
					"duration": 80
				},
				{
					"text": "I",
					"offset": 2560,
					"duration": 80
				},
				{
					"text": "speaking",
					"offset": 2640,
					"duration": 320
				},
				{
					"text": "with",
					"offset": 2960,
					"duration": 160
				},
				{
					"text": "today?",
					"offset": 3120,
					"duration": 320
				}
			],
			"locale": "en-US",
			"confidence": 0.9177142
		},
        // More transcription results removed for brevity
        // {...},
		{
			"channel": 1,
			"offset": 4480,
			"duration": 1600,
			"text": "Hi, my name is Mary Rondo.",
			"words": [
				{
					"text": "Hi,",
					"offset": 4480,
					"duration": 400
				},
				{
					"text": "my",
					"offset": 4880,
					"duration": 120
				},
				{
					"text": "name",
					"offset": 5000,
					"duration": 120
				},
				{
					"text": "is",
					"offset": 5120,
					"duration": 160
				},
				{
					"text": "Mary",
					"offset": 5280,
					"duration": 240
				},
				{
					"text": "Rondo.",
					"offset": 5520,
					"duration": 560
				}
			],
			"locale": "en-US",
			"confidence": 0.8989456
		},
		{
			"channel": 1,
			"offset": 6080,
			"duration": 1920,
			"text": "I'm trying to enroll myself with Contuso.",
			"words": [
				{
					"text": "I'm",
					"offset": 6080,
					"duration": 160
				},
				{
					"text": "trying",
					"offset": 6240,
					"duration": 200
				},
				{
					"text": "to",
					"offset": 6440,
					"duration": 80
				},
				{
					"text": "enroll",
					"offset": 6520,
					"duration": 200
				},
				{
					"text": "myself",
					"offset": 6720,
					"duration": 360
				},
				{
					"text": "with",
					"offset": 7080,
					"duration": 120
				},
				{
					"text": "Contuso.",
					"offset": 7200,
					"duration": 800
				}
			],
			"locale": "en-US",
			"confidence": 0.8989456
		},
        // More transcription results removed for brevity
        // {...},
	]
}