//native
type Assemblyai = {
apiKey: string;
};
/**
* Transcribe audio
* Create a transcript from a media file that is accessible via a URL.
*/
export async function main(
auth: Assemblyai,
body: { audio_url: string } & {
language_code?: string;
language_detection?: false | true;
language_confidence_threshold?: number;
speech_model?: "best" | "nano";
punctuate?: false | true;
format_text?: false | true;
disfluencies?: false | true;
multichannel?: false | true;
dual_channel?: false | true;
webhook_url?: string;
webhook_auth_header_name?: string;
webhook_auth_header_value?: string;
auto_highlights?: false | true;
audio_start_from?: number;
audio_end_at?: number;
word_boost?: string[];
boost_param?: "low" | "default" | "high";
filter_profanity?: false | true;
redact_pii?: false | true;
redact_pii_audio?: false | true;
redact_pii_audio_quality?: "mp3" | "wav";
redact_pii_policies?:
| "account_number"
| "banking_information"
| "blood_type"
| "credit_card_cvv"
| "credit_card_expiration"
| "credit_card_number"
| "date"
| "date_interval"
| "date_of_birth"
| "drivers_license"
| "drug"
| "duration"
| "email_address"
| "event"
| "filename"
| "gender_sexuality"
| "healthcare_number"
| "injury"
| "ip_address"
| "language"
| "location"
| "marital_status"
| "medical_condition"
| "medical_process"
| "money_amount"
| "nationality"
| "number_sequence"
| "occupation"
| "organization"
| "passport_number"
| "password"
| "person_age"
| "person_name"
| "phone_number"
| "physical_attribute"
| "political_affiliation"
| "religion"
| "statistics"
| "time"
| "url"
| "us_social_security_number"
| "username"
| "vehicle_id"
| "zodiac_sign"[];
redact_pii_sub?: "entity_name" | "hash";
speaker_labels?: false | true;
speakers_expected?: number;
content_safety?: false | true;
content_safety_confidence?: number;
iab_categories?: false | true;
custom_spelling?: { from: string[]; to: string }[];
sentiment_analysis?: false | true;
auto_chapters?: false | true;
entity_detection?: false | true;
speech_threshold?: number;
summarization?: false | true;
summary_model?: "informative" | "conversational" | "catchy";
summary_type?:
| "bullets"
| "bullets_verbose"
| "gist"
| "headline"
| "paragraph";
custom_topics?: false | true;
topics?: string[];
},
) {
const url = new URL(`https://api.assemblyai.com/v2/transcript`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 33 days ago