Delen via


Gebruik de snelle transcriptie-API met Azure AI Speech

De snelle transcriptie-API wordt gebruikt om audiobestanden te transcriberen, waarbij resultaten synchroon en sneller dan in realtime worden teruggegeven. Gebruik snelle transcriptie in situaties waarin u zo snel mogelijk de transcriptie van een audio-opname nodig heeft met voorspelbare latentie, zoals:

  • Snelle audio- of videotranscriptie, ondertiteling en bewerking.
  • Videotranslatie

In tegenstelling tot de batch-transcriptie-API produceert de snelle transcriptie-API alleen transcripties in de weergavevorm (niet de lexicale vorm). Het weergaveformulier is een meer leesbare vorm van de transcriptie die interpunctie en hoofdlettergebruik bevat.

Vereiste voorwaarden

  • Een Azure AI Speech-resource in een van de regio's waar de snelle transcriptie-API beschikbaar is. De ondersteunde regio's zijn: Australië East, Brazilië South, Centraal India, Oost VS, Oost VS 2, Centraal Frankrijk, Oost Japan, North Central VS, Noord Europa, South Central VS, Zuidoost Azië, Centraal Zweden, South UK, West Europa, West VS, West VS 2, West VS 3. Voor meer informatie over regio's die worden ondersteund voor andere functies van de Speech-service kunt u Speech serviced regio's raadplegen.

  • Een audiobestand (minder dan 2 uur lang en kleiner dan 300 MB) in een van de indelingen en codecs die worden ondersteund door de batchtranscriptie-API: WAV, MP3, OPUS/MSP, FLAC, WMA, AAC, ALAW in WAV-container, MULAW in WAV-container, WMV, WebM en SPEEX. Voor meer informatie over ondersteunde audioformaten, zie ondersteunde audioformaten.

De snelle transcriptie-API gebruiken

Aanbeveling

Probeer snelle transcriptie uit in de Azure AI Foundry-portal.

We leren hoe we de snelle transcriptie-API (via Transcriptions - Transcribe) kunnen gebruiken met de volgende scenario's:

  • Bekende regio gespecificeerd: Transcribeer een audiobestand met een gespecificeerde regio. Als je de taalinstelling van het audiobestand kent, kun je deze specificeren om de nauwkeurigheid van de transcriptie te verbeteren en de wachttijd te minimaliseren.
  • Taalherkenning ingeschakeld: Transcribeer een audiobestand met ingeschakelde taalherkenning. Als u niet zeker weet wat de landinstelling van het audiobestand is, kunt u taalidentificatie inschakelen zodat de Speech-service de landinstelling kan identificeren (één landinstelling per audio).
  • Meertalige transcriptie (preview): een audiobestand transcriberen met het nieuwste meertalige spraaktranscriptiemodel. Als uw audio meertalige inhoud bevat die u continu en nauwkeurig wilt transcriberen, kunt u het nieuwste meertalige spraaktranscriptiemodel gebruiken zonder de landinstellingencodes op te geven.
  • Diarization on: Transcribeer een audiobestand met diarization on. Diarisatie onderscheidt verschillende sprekers in het gesprek. De Speech-service biedt informatie over welke spreker een bepaald deel van de getranscribeerde spraak sprak.
  • Multi-channel aan: Transcribeer een audiobestand dat één of twee kanalen heeft. Meerkanaals transcripties zijn nuttig voor audio-bestanden met meerdere kanalen, zoals audio-bestanden met meerdere sprekers of audio-bestanden met achtergrondgeluid. De snelle transcriptie-API voegt standaard alle invoerkanalen samen in één kanaal en voert vervolgens de transcriptie uit. Als dit niet wenselijk is, kunnen kanalen onafhankelijk worden getranscribeerd zonder samenvoeging.

Maak een POST-aanvraag met meerdere onderdelen/formuliergegevens naar het transcriptions eindpunt met het audiobestand en de eigenschappen van de aanvraagbody.

Het volgende voorbeeld laat zien hoe je een audiobestand kunt transcriberen met een opgegeven landinstelling. Als je de taalinstelling van het audiobestand kent, kun je deze specificeren om de nauwkeurigheid van de transcriptie te verbeteren en de wachttijd te minimaliseren.

  • Vervang YourSpeechResoureKey door uw Speech resource key.
  • Vervang YourServiceRegion door uw spraakbronnenregio.
  • Vervang YourAudioFile door het pad naar uw audiobestand.

Belangrijk

Voor de aanbevolen sleutelloze verificatie met Microsoft Entra ID, vervangt u --header 'Ocp-Apim-Subscription-Key: YourSpeechResoureKey' door --header "Authorization: Bearer YourAccessToken". Zie de handleiding voor op rollen gebaseerd toegangsbeheer voor meer informatie over sleutelloze verificatie.

curl --location 'https://YourServiceRegion.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=2024-11-15' \
--header 'Content-Type: multipart/form-data' \
--header 'Ocp-Apim-Subscription-Key: YourSpeechResoureKey' \
--form 'audio=@"YourAudioFile"' \
--form 'definition="{
    "locales":["en-US"]}"'

Bouw de formulierdefinitie volgens de volgende instructies:

  • Stel de optionele (maar aanbevolen) locales eigenschap in die moet overeenkomen met de verwachte landinstelling van de audiogegevens om te transcriberen. In dit voorbeeld is de locatie ingesteld op en-US. Zie spraak-naar-tekst ondersteunde talen voor meer informatie over de ondersteunde landinstellingen.

Voor meer informatie over locales en andere eigenschappen van de snelle transcriptie-API, zie de sectie verzoekconfiguratieopties later in deze gids.

De reactie omvat durationMilliseconds, offsetMilliseconds en meer. De combinedPhrases eigenschap bevat de volledige transcripties voor alle sprekers.

{
	"durationMilliseconds": 182439,
	"combinedPhrases": [
		{
			"text": "Good afternoon. This is Sam. Thank you for calling Contoso. How can I help? Hi there. My name is Mary. I'm currently living in Los Angeles, but I'm planning to move to Las Vegas. I would like to apply for a loan. Okay. I see you're currently living in California. Let me make sure I understand you correctly. Uh You'd like to apply for a loan even though you'll be moving soon. Is that right? Yes, exactly. So I'm planning to relocate soon, but I would like to apply for the loan first so that I can purchase a new home once I move there. And are you planning to sell your current home? Yes, I will be listing it on the market soon and hopefully it'll sell quickly. That's why I'm applying for a loan now, so that I can purchase a new house in Nevada and close on it quickly as well once my current home sells. I see. Would you mind holding for a moment while I take your information down? Yeah, no problem. Thank you for your help. Mm-hmm. Just one moment. All right. Thank you for your patience, ma'am. May I have your first and last name, please? Yes, my name is Mary Smith. Thank you, Ms. Smith. May I have your current address, please? Yes. So my address is 123 Main Street in Los Angeles, California, and the zip code is 90923. Sorry, that was a 90 what? 90923. 90923 on Main Street. Got it. Thank you. May I have your phone number as well, please? Uh Yes, my phone number is 504-529-2351 and then yeah. 2351. Got it. And do you have an e-mail address we I can associate with this application? uh Yes, so my e-mail address is mary.a.sm78@gmail.com. Mary.a, was that a S-N as in November or M as in Mike? M as in Mike. Mike78, got it. Thank you. Ms. Smith, do you currently have any other loans? Uh Yes, so I currently have two other loans through Contoso. So my first one is my car loan and then my other is my student loan. They total about 1400 per month combined and my interest rate is 8%. I see. And you're currently paying those loans off monthly, is that right? Yes, of course I do. OK, thank you. Here's what I suggest we do. Let me place you on a brief hold again so that I can talk with one of our loan officers and get this started for you immediately. In the meantime, it would be great if you could take a few minutes and complete the remainder of the secure application online at www.contosoloans.com. Yeah, that sounds good. I can go ahead and get started. Thank you for your help. Thank you."
		}
	],
	"phrases": [
		{
			"offsetMilliseconds": 960,
			"durationMilliseconds": 640,
			"text": "Good afternoon.",
			"words": [
				{
					"text": "Good",
					"offsetMilliseconds": 960,
					"durationMilliseconds": 240
				},
				{
					"text": "afternoon.",
					"offsetMilliseconds": 1200,
					"durationMilliseconds": 400
				}
			],
			"locale": "en-US",
			"confidence": 0.93554276
		},
		{
			"offsetMilliseconds": 1600,
			"durationMilliseconds": 640,
			"text": "This is Sam.",
			"words": [
				{
					"text": "This",
					"offsetMilliseconds": 1600,
					"durationMilliseconds": 240
				},
				{
					"text": "is",
					"offsetMilliseconds": 1840,
					"durationMilliseconds": 120
				},
				{
					"text": "Sam.",
					"offsetMilliseconds": 1960,
					"durationMilliseconds": 280
				}
			],
			"locale": "en-US",
			"confidence": 0.93554276
		},
		{
			"offsetMilliseconds": 2240,
			"durationMilliseconds": 1040,
			"text": "Thank you for calling Contoso.",
			"words": [
				{
					"text": "Thank",
					"offsetMilliseconds": 2240,
					"durationMilliseconds": 200
				},
				{
					"text": "you",
					"offsetMilliseconds": 2440,
					"durationMilliseconds": 80
				},
				{
					"text": "for",
					"offsetMilliseconds": 2520,
					"durationMilliseconds": 120
				},
				{
					"text": "calling",
					"offsetMilliseconds": 2640,
					"durationMilliseconds": 200
				},
				{
					"text": "Contoso.",
					"offsetMilliseconds": 2840,
					"durationMilliseconds": 440
				}
			],
			"locale": "en-US",
			"confidence": 0.93554276
		},
		{
			"offsetMilliseconds": 3280,
			"durationMilliseconds": 640,
			"text": "How can I help?",
			"words": [
				{
					"text": "How",
					"offsetMilliseconds": 3280,
					"durationMilliseconds": 120
				},
				{
					"text": "can",
					"offsetMilliseconds": 3440,
					"durationMilliseconds": 120
				},
				{
					"text": "I",
					"offsetMilliseconds": 3560,
					"durationMilliseconds": 40
				},
				{
					"text": "help?",
					"offsetMilliseconds": 3600,
					"durationMilliseconds": 320
				}
			],
			"locale": "en-US",
			"confidence": 0.93554276
		},
		{
			"offsetMilliseconds": 5040,
			"durationMilliseconds": 400,
			"text": "Hi there.",
			"words": [
				{
					"text": "Hi",
					"offsetMilliseconds": 5040,
					"durationMilliseconds": 240
				},
				{
					"text": "there.",
					"offsetMilliseconds": 5280,
					"durationMilliseconds": 160
				}
			],
			"locale": "en-US",
			"confidence": 0.93554276
		},
		{
			"offsetMilliseconds": 5440,
			"durationMilliseconds": 800,
			"text": "My name is Mary.",
			"words": [
				{
					"text": "My",
					"offsetMilliseconds": 5440,
					"durationMilliseconds": 80
				},
				{
					"text": "name",
					"offsetMilliseconds": 5520,
					"durationMilliseconds": 120
				},
				{
					"text": "is",
					"offsetMilliseconds": 5640,
					"durationMilliseconds": 80
				},
				{
					"text": "Mary.",
					"offsetMilliseconds": 5720,
					"durationMilliseconds": 520
				}
			],
			"locale": "en-US",
			"confidence": 0.93554276
		},
		// More transcription results...
	    // Redacted for brevity
		{
			"offsetMilliseconds": 180320,
			"durationMilliseconds": 680,
			"text": "Thank you for your help.",
			"words": [
				{
					"text": "Thank",
					"offsetMilliseconds": 180320,
					"durationMilliseconds": 160
				},
				{
					"text": "you",
					"offsetMilliseconds": 180480,
					"durationMilliseconds": 80
				},
				{
					"text": "for",
					"offsetMilliseconds": 180560,
					"durationMilliseconds": 120
				},
				{
					"text": "your",
					"offsetMilliseconds": 180680,
					"durationMilliseconds": 120
				},
				{
					"text": "help.",
					"offsetMilliseconds": 180800,
					"durationMilliseconds": 200
				}
			],
			"locale": "en-US",
			"confidence": 0.92022026
		},
		{
			"offsetMilliseconds": 181960,
			"durationMilliseconds": 280,
			"text": "Thank you.",
			"words": [
				{
					"text": "Thank",
					"offsetMilliseconds": 181960,
					"durationMilliseconds": 200
				},
				{
					"text": "you.",
					"offsetMilliseconds": 182160,
					"durationMilliseconds": 80
				}
			],
			"locale": "en-US",
			"confidence": 0.92022026
		}
	]
}

Opmerking

Spraakdienst is een flexibele dienst. Als je foutcode 429 (te veel aanvragen) ontvangt, volg dan de beste praktijken om het afknijpen tijdens autoscaling te verminderen.

Verzoek om configuratieopties

Hier zijn enkele eigenschappenopties om een transcriptie te configureren wanneer u de Transcriptions - Transcribe operatie oproept.

Eigendom Beschrijving Verplicht of optioneel
channels De lijst met nul-gebaseerde indexen van de kanalen die afzonderlijk getranscribeerd moeten worden. Er worden maximaal twee kanalen ondersteund, tenzij er diarization is ingeschakeld. De snelle transcriptie-API voegt standaard alle invoerkanalen samen in één kanaal en voert vervolgens de transcriptie uit. Als dit niet wenselijk is, kunnen kanalen onafhankelijk worden getranscribeerd zonder samenvoeging.

Als je de kanalen van een stereogeluidsbestand afzonderlijk wilt transcriberen, moet je [0,1], [0], of [1] specificeren. Anders wordt stereogeluid samengevoegd met mono en wordt slechts één kanaal getranscribeerd.

Als het geluid stereo is en diarisatie is ingeschakeld, kun je de channels eigenschap niet instellen op [0,1]. De Speech-service biedt geen ondersteuning voor diarisatie van meerdere kanalen.

Voor mono-audio wordt de channels eigenschap genegeerd en wordt de audio altijd getranscribeerd als een enkel kanaal.
Optioneel
diarization De diariseringsconfiguratie. Diarisatie is het proces van het herkennen en scheiden van meerdere sprekers in één audiokanaal. Bijvoorbeeld, specificeer "diarization": {"maxSpeakers": 2, "enabled": true}. Vervolgens bevat het transcriptiebestand speaker items (zoals "speaker": 0 of "speaker": 1) voor elke getranscribeerde zin. Optioneel
locales De lijst met locaties die moeten overeenkomen met de verwachte locatie van de audiodata om te transcriberen.

Als je de taalinstelling van het audiobestand kent, kun je deze specificeren om de nauwkeurigheid van de transcriptie te verbeteren en de wachttijd te minimaliseren. Als er één landinstelling is opgegeven, wordt die landinstelling gebruikt voor transcriptie.

Maar als u niet zeker weet wat de landinstelling is, kunt u meerdere landinstellingen opgeven om taalidentificatie te gebruiken. Taalidentificatie kan nauwkeuriger zijn met een meer precieze lijst van kandidaat locaties.

Als u geen landinstellingen opgeeft, gebruikt de Speech-service het nieuwste meertalige model om de landinstelling te identificeren en continu te transcriberen.

U kunt de meest recente ondersteunde talen ophalen via de Transcripties - List Supported Locales REST API (API versie 2024-11-15 of hoger). Voor meer informatie over locale-instellingen kunt u de documentatie Ondersteuning van spraakdiensttalen raadplegen.
Optioneel, maar aanbevolen als u de verwachte locaalinstelling kent.
profanityFilterMode Hiermee geeft u op hoe grof taalgebruik moet worden verwerkt in herkenningsresultaten. Geaccepteerde waarden zijn None om grof taalgebruik uit te schakelen, Masked grof taalgebruik te vervangen door sterretjes, Removed om alle grof taalgebruik uit het resultaat te verwijderen of Tags om grof taalgebruikslabels toe te voegen. De standaardwaarde is Masked. Optioneel