Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions fern/pages/08-speech-understanding/translation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ audio_url = "https://assembly.ai/wildfires.mp3"
data = {
"audio_url": audio_url,
"speaker_labels": True, # Enable speaker labels
# "language_detection": True, # Enable language detection if you are processing files in a variety of languages
"speech_understanding": {
"request": {
"translation": {
Expand Down Expand Up @@ -223,6 +224,7 @@ transcriber = aai.Transcriber()
# Configure transcription with translation
config = aai.TranscriptionConfig(
speaker_labels=True, # Enable speaker labels
# language_detection=True, # Enable language detection if you are processing files in a variety of languages
speech_understanding=aai.SpeechUnderstandingConfig(
translation=aai.TranslationConfig(
target_languages=['es', 'de'], # Translate to Spanish and German
Expand Down Expand Up @@ -266,6 +268,7 @@ const audioUrl = 'https://assembly.ai/wildfires.mp3';
const data = {
audio_url: audioUrl,
speaker_labels: true, // Enable speaker labels
// language_detection: true, // Enable language detection if you are processing files in a variety of languages
speech_understanding: {
request: {
translation: {
Expand Down Expand Up @@ -332,6 +335,7 @@ const client = new AssemblyAI({
const config = {
audio_url: 'https://assembly.ai/wildfires.mp3',
speaker_labels: true, // Enable speaker labels
// language_detection: true, // Enable language detection if you are processing files in a variety of languages
speech_understanding: {
request: {
translation: {
Expand Down Expand Up @@ -359,7 +363,7 @@ if (transcript.translated_texts) {
}
```

</Tab> */}
</Tab> */}
</Tabs>

### Method 2: Transcribe and translate in separate requests
Expand All @@ -385,7 +389,8 @@ audio_url = "https://assembly.ai/wildfires.mp3"
# Submit transcription request (without translation)
data = {
"audio_url": audio_url,
"speaker_labels": True
"speaker_labels": True,
# "language_detection": True, # Enable language detection if you are processing files in a variety of languages
}

# Transcribe file
Expand Down Expand Up @@ -452,6 +457,7 @@ audio_url = "https://assembly.ai/wildfires.mp3"

config = aai.TranscriptionConfig(
speaker_labels=True,
# language_detection=True, # Enable language detection if you are processing files in a variety of languages
)
transcript = aai.Transcriber().transcribe(audio_file, config)

Expand Down Expand Up @@ -504,7 +510,8 @@ async function main() {
// Submit transcription request (without translation)
const data = {
audio_url: audioUrl,
speaker_labels: true
speaker_labels: true,
// language_detection: true, // Enable language detection if you are processing files in a variety of languages
};

// Transcribe file
Expand Down Expand Up @@ -601,6 +608,7 @@ async function translateTranscript() {
const transcript = await client.transcripts.transcribe({
audio: audioUrl,
speaker_labels: true // Optional: enable speaker diarization
// language_detection: true, // Enable language detection if you are processing files in a variety of languages
});

if (transcript.status === "error") {
Expand Down Expand Up @@ -634,7 +642,7 @@ async function translateTranscript() {
translateTranscript().catch(console.error);
```

</Tab> */}
</Tab> */}
</Tabs>

**Expected output:**
Expand Down Expand Up @@ -733,6 +741,7 @@ audio_url = "https://assembly.ai/wildfires.mp3"
data = {
"audio_url": audio_url,
"speaker_labels": True, # Enable speaker labels
# "language_detection": True, # Enable language detection if you are processing files in a variety of languages
"speech_understanding": {
"request": {
"translation": {
Expand Down Expand Up @@ -787,6 +796,7 @@ const audioUrl = 'https://assembly.ai/wildfires.mp3';
const data = {
audio_url: audioUrl,
speaker_labels: true, // Enable speaker labels
// language_detection: true, // Enable language detection if you are processing files in a variety of languages
speech_understanding: {
request: {
translation: {
Expand Down Expand Up @@ -889,6 +899,7 @@ curl -X POST \
-d '{
"audio_url": "https://assembly.ai/wildfires.mp3",
"speaker_labels": true,
"language_detection": true,
"speech_understanding": {
"request": {
"translation": {
Expand Down
Loading