assemblyai
Version:
The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.
1,558 lines (1,557 loc) • 106 kB
TypeScript
import { LiteralUnion } from "./helpers";
/** OneOf type helpers */
type Without<T, U> = {
[P in Exclude<keyof T, keyof U>]?: never;
};
type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
type OneOf<T extends any[]> = T extends [infer Only] ? Only : T extends [infer A, infer B, ...infer Rest] ? OneOf<[XOR<A, B>, ...Rest]> : never;
/**
* Either success, or unavailable in the rare case that the model failed
*/
export type AudioIntelligenceModelStatus = "success" | "unavailable";
/**
* @example
* ```js
* {
* "count": 1,
* "rank": 0.08,
* "text": "air quality alerts",
* "timestamps": [
* {
* "start": 3978,
* "end": 5114
* }
* ]
* }
* ```
*/
export type AutoHighlightResult = {
/**
* The total number of times the key phrase appears in the audio file
*/
count: number;
/**
* The total relevancy to the overall audio file of this key phrase - a greater number means more relevant
*/
rank: number;
/**
* The text itself of the key phrase
*/
text: string;
/**
* The timestamp of the of the key phrase
*/
timestamps: Timestamp[];
};
/**
* An array of results for the Key Phrases model, if it is enabled.
* See {@link https://www.assemblyai.com/docs/models/key-phrases | Key phrases } for more information.
*
* @example
* ```js
* {
* "status": "success",
* "results": [
* {
* "count": 1,
* "rank": 0.08,
* "text": "air quality alerts",
* "timestamps": [
* {
* "start": 3978,
* "end": 5114
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.08,
* "text": "wide ranging air quality consequences",
* "timestamps": [
* {
* "start": 235388,
* "end": 238694
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.07,
* "text": "more wildfires",
* "timestamps": [
* {
* "start": 230972,
* "end": 232354
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.07,
* "text": "air pollution",
* "timestamps": [
* {
* "start": 156004,
* "end": 156910
* }
* ]
* },
* {
* "count": 3,
* "rank": 0.07,
* "text": "weather systems",
* "timestamps": [
* {
* "start": 47344,
* "end": 47958
* },
* {
* "start": 205268,
* "end": 205818
* },
* {
* "start": 211588,
* "end": 213434
* }
* ]
* },
* {
* "count": 2,
* "rank": 0.06,
* "text": "high levels",
* "timestamps": [
* {
* "start": 121128,
* "end": 121646
* },
* {
* "start": 155412,
* "end": 155866
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.06,
* "text": "health conditions",
* "timestamps": [
* {
* "start": 152138,
* "end": 152666
* }
* ]
* },
* {
* "count": 2,
* "rank": 0.06,
* "text": "Peter de Carlo",
* "timestamps": [
* {
* "start": 18948,
* "end": 19930
* },
* {
* "start": 268298,
* "end": 269194
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.06,
* "text": "New York City",
* "timestamps": [
* {
* "start": 125768,
* "end": 126274
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.05,
* "text": "respiratory conditions",
* "timestamps": [
* {
* "start": 152964,
* "end": 153786
* }
* ]
* },
* {
* "count": 3,
* "rank": 0.05,
* "text": "New York",
* "timestamps": [
* {
* "start": 125768,
* "end": 126034
* },
* {
* "start": 171448,
* "end": 171938
* },
* {
* "start": 176008,
* "end": 176322
* }
* ]
* },
* {
* "count": 3,
* "rank": 0.05,
* "text": "climate change",
* "timestamps": [
* {
* "start": 229548,
* "end": 230230
* },
* {
* "start": 244576,
* "end": 245162
* },
* {
* "start": 263348,
* "end": 263950
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.05,
* "text": "Johns Hopkins University Varsity",
* "timestamps": [
* {
* "start": 23972,
* "end": 25490
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.05,
* "text": "heart conditions",
* "timestamps": [
* {
* "start": 153988,
* "end": 154506
* }
* ]
* },
* {
* "count": 1,
* "rank": 0.05,
* "text": "air quality warnings",
* "timestamps": [
* {
* "start": 12308,
* "end": 13434
* }
* ]
* }
* ]
* }
* ```
*/
export type AutoHighlightsResult = {
/**
* A temporally-sequential array of Key Phrases
*/
results: AutoHighlightResult[];
/**
* The status of the Key Phrases model. Either success, or unavailable in the rare case that the model failed.
*/
status: AudioIntelligenceModelStatus;
};
/**
* Chapter of the audio file
* @example
* ```js
* {
* "summary": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines from Maine to Maryland to Minnesota are gray and smoggy. In some places, the air quality warnings include the warning to stay inside.",
* "gist": "Smoggy air quality alerts across US",
* "headline": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts across US",
* "start": 250,
* "end": 28840
* }
* ```
*/
export type Chapter = {
/**
* The starting time, in milliseconds, for the chapter
*/
end: number;
/**
* An ultra-short summary (just a few words) of the content spoken in the chapter
*/
gist: string;
/**
* A single sentence summary of the content spoken during the chapter
*/
headline: string;
/**
* The starting time, in milliseconds, for the chapter
*/
start: number;
/**
* A one paragraph summary of the content spoken during the chapter
*/
summary: string;
};
/**
* @example
* ```js
* {
* "label": "disasters",
* "confidence": 0.8142836093902588,
* "severity": 0.4093044400215149
* }
* ```
*/
export type ContentSafetyLabel = {
/**
* The confidence score for the topic being discussed, from 0 to 1
*/
confidence: number;
/**
* The label of the sensitive topic
*/
label: string;
/**
* How severely the topic is discussed in the section, from 0 to 1
*/
severity: number;
};
/**
* @example
* ```js
* {
* "text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines from Maine to Maryland to Minnesota are gray and smoggy. And in some places, the air quality warnings include the warning to stay inside. We wanted to better understand what's happening here and why, so we called Peter de Carlo, an associate professor in the Department of Environmental Health and Engineering at Johns Hopkins University Varsity. Good morning, professor. Good morning.",
* "labels": [
* {
* "label": "disasters",
* "confidence": 0.8142836093902588,
* "severity": 0.4093044400215149
* }
* ],
* "sentences_idx_start": 0,
* "sentences_idx_end": 5,
* "timestamp": {
* "start": 250,
* "end": 28840
* }
* }
* ```
*/
export type ContentSafetyLabelResult = {
/**
* An array of safety labels, one per sensitive topic that was detected in the section
*/
labels: ContentSafetyLabel[];
/**
* The sentence index at which the section ends
*/
sentences_idx_end: number;
/**
* The sentence index at which the section begins
*/
sentences_idx_start: number;
/**
* The transcript of the section flagged by the Content Moderation model
*/
text: string;
/**
* Timestamp information for the section
*/
timestamp: Timestamp;
};
/**
* An array of results for the Content Moderation model, if it is enabled.
* See {@link https://www.assemblyai.com/docs/models/content-moderation | Content moderation } for more information.
*
* @example
* ```js
* {
* "status": "success",
* "results": [
* {
* "text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines from Maine to Maryland to Minnesota are gray and smoggy. And in some places, the air quality warnings include the warning to stay inside. We wanted to better understand what's happening here and why, so we called Peter de Carlo, an associate professor in the Department of Environmental Health and Engineering at Johns Hopkins University Varsity. Good morning, professor. Good morning.",
* "labels": [
* {
* "label": "disasters",
* "confidence": 0.8142836093902588,
* "severity": 0.4093044400215149
* }
* ],
* "sentences_idx_start": 0,
* "sentences_idx_end": 5,
* "timestamp": {
* "start": 250,
* "end": 28840
* }
* }
* ],
* "summary": {
* "disasters": 0.9940800441842205,
* "health_issues": 0.9216489289040967
* },
* "severity_score_summary": {
* "disasters": {
* "low": 0.5733263024656846,
* "medium": 0.42667369753431533,
* "high": 0
* },
* "health_issues": {
* "low": 0.22863814977924785,
* "medium": 0.45014154926938227,
* "high": 0.32122030095136983
* }
* }
* }
* ```
*/
export type ContentSafetyLabelsResult = {
/**
* An array of results for the Content Moderation model
*/
results: ContentSafetyLabelResult[];
/**
* A summary of the Content Moderation severity results for the entire audio file
*/
severity_score_summary: {
[key: string]: SeverityScoreSummary;
};
/**
* The status of the Content Moderation model. Either success, or unavailable in the rare case that the model failed.
*/
status: AudioIntelligenceModelStatus;
/**
* A summary of the Content Moderation confidence results for the entire audio file
*/
summary: {
[key: string]: number;
};
};
/**
* @example
* ```js
* {
* "expires_in": 480
* }
* ```
*/
export type CreateRealtimeTemporaryTokenParams = {
/**
* The amount of time until the token expires in seconds
*/
expires_in: number;
};
/**
* A detected entity
* @example
* ```js
* {
* "entity_type": "location",
* "text": "Canada",
* "start": 2548,
* "end": 3130
* }
* ```
*/
export type Entity = {
/**
* The ending time, in milliseconds, for the detected entity in the audio file
*/
end: number;
/**
* The type of entity for the detected entity
*/
entity_type: EntityType;
/**
* The starting time, in milliseconds, at which the detected entity appears in the audio file
*/
start: number;
/**
* The text for the detected entity
*/
text: string;
};
/**
* The type of entity for the detected entity
*/
export type EntityType = "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";
/**
* @example
* ```js
* {
* "error": "format_text must be a Boolean"
* }
* ```
*/
export type Error = {
/**
* Error message
*/
error: string;
status?: "error";
[key: string]: unknown;
};
/**
* @example
* ```js
* {
* "transcript_ids": [
* "64nygnr62k-405c-4ae8-8a6b-d90b40ff3cce"
* ],
* "context": "This is an interview about wildfires.",
* "answer_format": "Bullet Points",
* "final_model": "anthropic/claude-3-5-sonnet",
* "temperature": 0,
* "max_output_size": 3000
* }
* ```
*/
export type LemurActionItemsParams = LemurBaseParams & {
/**
* How you want the action items to be returned. This can be any text.
* Defaults to "Bullet Points".
*
* @defaultValue "Bullet Points
*/
answer_format?: string;
};
/**
* @example
* ```js
* {
* "request_id": "5"e1b27c2-691f-4414-8bc5-f14678442f9e",
* "response": "Here are some potential action items based on the transcript:\n\n- Monitor air quality levels in affected areas and issue warnings as needed.\n\n- Advise vulnerable populations like children, the elderly, and those with respiratory conditions to limit time outdoors.\n\n- Have schools cancel outdoor activities when air quality is poor.\n\n- Educate the public on health impacts of smoke inhalation and precautions to take.\n\n- Track progression of smoke plumes using weather and air quality monitoring systems.\n\n- Coordinate cross-regionally to manage smoke exposure as air masses shift.\n\n- Plan for likely increase in such events due to climate change. Expand monitoring and forecasting capabilities.\n\n- Conduct research to better understand health impacts of wildfire smoke and mitigation strategies.\n\n- Develop strategies to prevent and manage wildfires to limit air quality impacts.\n",
* "usage": {
* "input_tokens": 27,
* "output_tokens": 3
* }
* }
* ```
*/
export type LemurActionItemsResponse = LemurStringResponse;
/**
* @example
* ```js
* {
* "transcript_ids": [
* "85f9b381-e90c-46ed-beca-7d76245d375e",
* "7c3acd18-df4d-4432-88f5-1e89f8827eea"
* ],
* "context": "This is an interview about wildfires.",
* "final_model": "anthropic/claude-3-5-sonnet",
* "temperature": 0,
* "max_output_size": 3000
* }
* ```
*/
export type LemurBaseParams = {
/**
* Context to provide the model. This can be a string or a free-form JSON value.
*/
context?: OneOf<[
string,
{
[key: string]: unknown;
}
]>;
/**
* The model that is used for the final prompt after compression is performed.
*
* @defaultValue "default
*/
final_model?: LiteralUnion<LemurModel, string>;
/**
* Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000".
* Use either transcript_ids or input_text as input into LeMUR.
*/
input_text?: string;
/**
* Max output size in tokens, up to 4000
* @defaultValue 2000
*/
max_output_size?: number;
/**
* The temperature to use for the model.
* Higher values result in answers that are more creative, lower values are more conservative.
* Can be any value between 0.0 and 1.0 inclusive.
*
* @defaultValue 0
*/
temperature?: number;
/**
* A list of completed transcripts with text. Up to a maximum of 100 files or 100 hours, whichever is lower.
* Use either transcript_ids or input_text as input into LeMUR.
*/
transcript_ids?: string[];
};
/**
* @example
* ```js
* {
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
* "usage": {
* "input_tokens": 27,
* "output_tokens": 3
* }
* }
* ```
*/
export type LemurBaseResponse = {
/**
* The ID of the LeMUR request
*/
request_id: string;
/**
* The usage numbers for the LeMUR request
*/
usage: LemurUsage;
};
/**
* The model that is used for the final prompt after compression is performed.
*
*/
export type LemurModel = "anthropic/claude-3-5-sonnet" | "anthropic/claude-3-opus" | "anthropic/claude-3-haiku" | "anthropic/claude-3-sonnet" | "anthropic/claude-2-1" | "anthropic/claude-2" | "default" | "assemblyai/mistral-7b";
/**
* @example
* ```js
* {
* "question": "Where are there wildfires?",
* "answer_format": "List of countries in ISO 3166-1 alpha-2 format"
* }
* ```
*/
export type LemurQuestion = {
/**
* How you want the answer to be returned. This can be any text. Can't be used with answer_options. Examples: "short sentence", "bullet points"
*/
answer_format?: string;
/**
* What discrete options to return. Useful for precise responses. Can't be used with answer_format. Example: ["Yes", "No"]
*/
answer_options?: string[];
/**
* Any context about the transcripts you wish to provide. This can be a string or any object.
*/
context?: OneOf<[
string,
{
[key: string]: unknown;
}
]>;
/**
* The question you wish to ask. For more complex questions use default model.
*/
question: string;
};
/**
* An answer generated by LeMUR and its question
* @example
* ```js
* {
* "answer": "CA, US",
* "question": "Where are there wildfires?"
* }
* ```
*/
export type LemurQuestionAnswer = {
/**
* The answer generated by LeMUR
*/
answer: string;
/**
* The question for LeMUR to answer
*/
question: string;
};
/**
* @example
* ```js
* {
* "transcript_ids": [
* "64nygnr62k-405c-4ae8-8a6b-d90b40ff3cce"
* ],
* "context": "This is an interview about wildfires.",
* "questions": [
* {
* "question": "Where are there wildfires?",
* "answer_format": "List of countries in ISO 3166-1 alpha-2 format",
* "answer_options": [
* "US",
* "CA"
* ]
* },
* {
* "question": "Is global warming affecting wildfires?",
* "answer_options": [
* "yes",
* "no"
* ]
* }
* ],
* "final_model": "anthropic/claude-3-5-sonnet",
* "temperature": 0,
* "max_output_size": 3000
* }
* ```
*/
export type LemurQuestionAnswerParams = LemurBaseParams & {
/**
* A list of questions to ask
*/
questions: LemurQuestion[];
};
/**
* @example
* ```js
* {
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
* "response": [
* {
* "answer": "CA, US",
* "question": "Where are there wildfires?"
* },
* {
* "answer": "yes",
* "question": "Is global warming affecting wildfires?"
* }
* ],
* "usage": {
* "input_tokens": 27,
* "output_tokens": 3
* }
* }
* ```
*/
export type LemurQuestionAnswerResponse = LemurBaseResponse & {
/**
* The answers generated by LeMUR and their questions
*/
response: LemurQuestionAnswer[];
};
export type LemurResponse = LemurStringResponse | LemurQuestionAnswerResponse;
/**
* @example
* ```js
* {
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
* "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n",
* "usage": {
* "input_tokens": 27,
* "output_tokens": 3
* }
* }
* ```
*/
export type LemurStringResponse = {
/**
* The response generated by LeMUR.
*/
response: string;
} & LemurBaseResponse;
/**
* @example
* ```js
* {
* "transcript_ids": [
* "47b95ba5-8889-44d8-bc80-5de38306e582"
* ],
* "context": "This is an interview about wildfires.",
* "final_model": "anthropic/claude-3-5-sonnet",
* "temperature": 0,
* "max_output_size": 3000
* }
* ```
*/
export type LemurSummaryParams = LemurBaseParams & {
/**
* How you want the summary to be returned. This can be any text. Examples: "TLDR", "bullet points"
*/
answer_format?: string;
};
/**
* @example
* ```js
* {
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
* "response": "- Wildfires in Canada are sending smoke and air pollution across parts of the US, triggering air quality alerts from Maine to Minnesota. Concentrations of particulate matter have exceeded safety levels.\n\n- Weather systems are channeling the smoke through Pennsylvania into the Mid-Atlantic and Northeast regions. New York City has canceled outdoor activities to keep children and vulnerable groups indoors.\n\n- Very small particulate matter can enter the lungs and impact respiratory, cardiovascular and neurological health. Young children, the elderly and those with preexisting conditions are most at risk.\n\n- The conditions causing the poor air quality could get worse or shift to different areas in coming days depending on weather patterns. More wildfires may also contribute to higher concentrations.\n\n- Climate change is leading to longer and more severe fire seasons. Events of smoke traveling long distances and affecting air quality over wide areas will likely become more common in the future.\"\n",
* "usage": {
* "input_tokens": 27,
* "output_tokens": 3
* }
* }
* ```
*/
export type LemurSummaryResponse = LemurStringResponse;
/**
* @example
* ```js
* {
* "transcript_ids": [
* "64nygnr62k-405c-4ae8-8a6b-d90b40ff3cce"
* ],
* "prompt": "List all the locations affected by wildfires.",
* "context": "This is an interview about wildfires.",
* "final_model": "anthropic/claude-3-5-sonnet",
* "temperature": 0,
* "max_output_size": 3000
* }
* ```
*/
export type LemurTaskParams = {
/**
* Your text to prompt the model to produce a desired output, including any context you want to pass into the model.
*/
prompt: string;
} & LemurBaseParams;
/**
* @example
* ```js
* {
* "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
* "response": "Based on the transcript, the following locations were mentioned as being affected by wildfire smoke from Canada:\n\n- Maine\n- Maryland\n- Minnesota\n- Mid Atlantic region\n- Northeast region\n- New York City\n- Baltimore\n",
* "usage": {
* "input_tokens": 27,
* "output_tokens": 3
* }
* }
* ```
*/
export type LemurTaskResponse = LemurStringResponse;
/**
* The usage numbers for the LeMUR request
*/
export type LemurUsage = {
/**
* The number of input tokens used by the model
*/
input_tokens: number;
/**
* The number of output tokens generated by the model
*/
output_tokens: number;
};
/**
* @example
* ```js
* {
* "after_id": "a7c5cafd-2c2e-4bdd-b0b2-69dade2f7a1b",
* "before_id": "9ea68fd3-f953-42c1-9742-976c447fb463",
* "created_on": "2023-11-03",
* "limit": 2,
* "status": "completed",
* "throttled_only": false
* }
* ```
*/
export type ListTranscriptParams = {
/**
* Get transcripts that were created after this transcript ID
*/
after_id?: string;
/**
* Get transcripts that were created before this transcript ID
*/
before_id?: string;
/**
* Only get transcripts created on this date
*/
created_on?: string;
/**
* Maximum amount of transcripts to retrieve
* @defaultValue 10
*/
limit?: number;
/**
* Filter by transcript status
*/
status?: TranscriptStatus;
/**
* Only get throttled transcripts, overrides the status filter
* @defaultValue false
* @deprecated
*/
throttled_only?: boolean;
};
/**
* Details of the transcript page. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
* @example
* ```js
* {
* "limit": 10,
* "result_count": 10,
* "current_url": "https://api.assemblyai.com/v2/transcript?limit=10",
* "prev_url": "https://api.assemblyai.com/v2/transcript?limit=10&before_id=62npeahu2b-a8ea-4112-854c-69542c20d90c",
* "next_url": "https://api.assemblyai.com/v2/transcript?limit=10&after_id=62nfw3mlar-01ad-4631-92f6-629929496eed"
* }
* ```
*/
export type PageDetails = {
/**
* The URL used to retrieve the current page of transcripts
*/
current_url: string;
/**
* The number of results this page is limited to
*/
limit: number;
/**
* The URL to the next page of transcripts. The next URL always points to a page with newer transcripts.
*/
next_url: string | null;
/**
* The URL to the next page of transcripts. The previous URL always points to a page with older transcripts.
*/
prev_url: string | null;
/**
* The actual number of results in the page
*/
result_count: number;
};
/**
* @example
* ```js
* {
* "paragraphs": [
* {
* "text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines from Maine to Maryland to Minnesota are gray and smoggy. And in some places, the air quality warnings include the warning to stay inside. We wanted to better understand what's happening here and why, so we called Peter Decarlo, an associate professor in the Department of Environmental Health and Engineering at Johns Hopkins University. Good morning, professor.",
* "start": 250,
* "end": 26950,
* "confidence": 0.73033,
* "words": [
* {
* "text": "Smoke",
* "start": 250,
* "end": 650,
* "confidence": 0.73033,
* "speaker": null
* },
* {
* "text": "from",
* "start": 730,
* "end": 1022,
* "confidence": 1,
* "speaker": null
* },
* {
* "text": "hundreds",
* "start": 1076,
* "end": 1466,
* "confidence": 0.99992,
* "speaker": null
* },
* {
* "text": "of",
* "start": 1498,
* "end": 1646,
* "confidence": 1,
* "speaker": null
* }
* ]
* },
* {
* "text": "Good morning. So what is it about the conditions right now that have caused this round of wildfires to affect so many people so far away? Well, there's a couple of things. The season has been pretty dry already, and then the fact that we're getting hit in the US. Is because there's a couple of weather systems that are essentially channeling the smoke from those Canadian wildfires through Pennsylvania into the Mid Atlantic and the Northeast and kind of just dropping the smoke there.",
* "start": 27850,
* "end": 56190,
* "confidence": 0.99667,
* "words": [
* {
* "text": "Good",
* "start": 27850,
* "end": 28262,
* "confidence": 0.99667,
* "speaker": null
* },
* {
* "text": "morning.",
* "start": 28316,
* "end": 28920,
* "confidence": 0.99742,
* "speaker": null
* },
* {
* "text": "So",
* "start": 29290,
* "end": 29702,
* "confidence": 0.94736,
* "speaker": null
* }
* ]
* }
* ],
* "id": "d5a3d302-066e-43fb-b63b-8f57baf185db",
* "confidence": 0.9578730257009361,
* "audio_duration": 281
* }
* ```
*/
export type ParagraphsResponse = {
/**
* The duration of the audio file in seconds
*/
audio_duration: number;
/**
* The confidence score for the transcript
*/
confidence: number;
/**
* The unique identifier of your transcript
*/
id: string;
/**
* An array of paragraphs in the transcript
*/
paragraphs: TranscriptParagraph[];
};
/**
* The type of PII to redact
*/
export type PiiPolicy = "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";
/**
* @example
* ```js
* {
* "request_id": "914fe7e4-f10a-4364-8946-34614c2873f6",
* "request_id_to_purge": "b7eb03ec-1650-4181-949b-75d9de317de1",
* "deleted": true
* }
* ```
*/
export type PurgeLemurRequestDataResponse = {
/**
* Whether the request data was deleted
*/
deleted: boolean;
/**
* The ID of the deletion request of the LeMUR request
*/
request_id: string;
/**
* The ID of the LeMUR request to purge the data for
*/
request_id_to_purge: string;
};
/**
* @example
* ```js
* {
* "token": "fe4145dd1e7a2e149488dcd2d553a8018a89833fc5084837d66fd1bcf5a105d4"
* }
* ```
*/
export type RealtimeTemporaryTokenResponse = {
/**
* The temporary authentication token for Streaming Speech-to-Text
*/
token: string;
};
/**
* The notification when the redacted audio is ready.
*/
export type RedactedAudioNotification = RedactedAudioResponse;
/**
* @example
* ```js
* {
* "redacted_audio_url": "https://s3.us-west-2.amazonaws.com/api.assembly.ai.usw2/redacted-audio/785efd9e-0e20-45e1-967b-3db17770ed9f.wav?AWSAccessKeyId=aws-access-key0id&Signature=signature&x-amz-security-token=security-token&Expires=1698966551",
* "status": "redacted_audio_ready"
* }
* ```
*/
export type RedactedAudioResponse = {
/**
* The URL of the redacted audio file
*/
redacted_audio_url: string;
/**
* The status of the redacted audio
*/
status: RedactedAudioStatus;
};
/**
* The status of the redacted audio
*/
export type RedactedAudioStatus = "redacted_audio_ready";
/**
* Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav. See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.
* @example "mp3"
*/
export type RedactPiiAudioQuality = "mp3" | "wav";
/**
* @example
* ```js
* {
* "sentences": [
* {
* "text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US.",
* "start": 250,
* "end": 6350,
* "confidence": 0.72412,
* "words": [
* {
* "text": "Smoke",
* "start": 250,
* "end": 650,
* "confidence": 0.72412,
* "speaker": null
* },
* {
* "text": "from",
* "start": 730,
* "end": 1022,
* "confidence": 0.99996,
* "speaker": null
* },
* {
* "text": "hundreds",
* "start": 1076,
* "end": 1466,
* "confidence": 0.99992,
* "speaker": null
* },
* {
* "text": "of",
* "start": 1498,
* "end": 1646,
* "confidence": 1,
* "speaker": null
* }
* ],
* "speaker": null
* },
* {
* "text": "Skylines from Maine to Maryland to Minnesota are gray and smoggy.",
* "start": 6500,
* "end": 11050,
* "confidence": 0.99819,
* "words": [
* {
* "text": "Skylines",
* "start": 6500,
* "end": 7306,
* "confidence": 0.99819,
* "speaker": null
* },
* {
* "text": "from",
* "start": 7338,
* "end": 7534,
* "confidence": 0.99987,
* "speaker": null
* },
* {
* "text": "Maine",
* "start": 7572,
* "end": 7962,
* "confidence": 0.9972,
* "speaker": null
* },
* {
* "text": "to",
* "start": 8026,
* "end": 8206,
* "confidence": 1,
* "speaker": null
* },
* {
* "text": "Maryland",
* "start": 8228,
* "end": 8650,
* "confidence": 0.5192,
* "speaker": null
* },
* {
* "text": "to",
* "start": 8730,
* "end": 8926,
* "confidence": 1,
* "speaker": null
* }
* ],
* "speaker": null
* }
* ],
* "id": "d5a3d302-066e-43fb-b63b-8f57baf185db",
* "confidence": 0.9579390654205628,
* "audio_duration": 281
* }
* ```
*/
export type SentencesResponse = {
/**
* The duration of the audio file in seconds
*/
audio_duration: number;
/**
* The confidence score for the transcript
*/
confidence: number;
/**
* The unique identifier for the transcript
*/
id: string;
/**
* An array of sentences in the transcript
*/
sentences: TranscriptSentence[];
};
export type Sentiment = "POSITIVE" | "NEUTRAL" | "NEGATIVE";
/**
* The result of the Sentiment Analysis model
* @example
* ```js
* {
* "text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US.",
* "start": 250,
* "end": 6350,
* "sentiment": "NEGATIVE",
* "confidence": 0.8181032538414001,
* "speaker": null
* }
* ```
*/
export type SentimentAnalysisResult = {
/**
* The channel of this utterance. The left and right channels are channels 1 and 2. Additional channels increment the channel number sequentially.
*/
channel?: string | null;
/**
* The confidence score for the detected sentiment of the sentence, from 0 to 1
*/
confidence: number;
/**
* The ending time, in milliseconds, of the sentence
*/
end: number;
/**
* The detected sentiment for the sentence, one of POSITIVE, NEUTRAL, NEGATIVE
*/
sentiment: Sentiment;
/**
* The speaker of the sentence if {@link https://www.assemblyai.com/docs/models/speaker-diarization | Speaker Diarization } is enabled, else null
*/
speaker: string | null;
/**
* The starting time, in milliseconds, of the sentence
*/
start: number;
/**
* The transcript of the sentence
*/
text: string;
};
/**
* @example
* ```js
* {
* "low": 0.5733263024656846,
* "medium": 0.42667369753431533,
* "high": 0
* }
* ```
*/
export type SeverityScoreSummary = {
high: number;
low: number;
medium: number;
};
/**
* The speech model to use for the transcription.
*/
export type SpeechModel = "best" | "nano" | "slam-1";
/**
* The replacement logic for detected PII, can be "entity_name" or "hash". See {@link https://www.assemblyai.com/docs/models/pii-redaction | PII redaction } for more details.
*/
export type SubstitutionPolicy = "entity_name" | "hash";
/**
* Format of the subtitles
*/
export type SubtitleFormat = "srt" | "vtt";
/**
* The model to summarize the transcript
*/
export type SummaryModel = "informative" | "conversational" | "catchy";
/**
* The type of summary
*/
export type SummaryType = "bullets" | "bullets_verbose" | "gist" | "headline" | "paragraph";
/**
* Timestamp containing a start and end property in milliseconds
* @example
* ```js
* {
* "start": 3978,
* "end": 5114
* }
* ```
*/
export type Timestamp = {
/**
* The end time in milliseconds
*/
end: number;
/**
* The start time in milliseconds
*/
start: number;
};
/**
* The result of the Topic Detection model, if it is enabled.
* See {@link https://www.assemblyai.com/docs/models/topic-detection | Topic Detection } for more information.
*
* @example
* ```js
* {
* "status": "success",
* "results": [
* {
* "text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines from Maine to Maryland to Minnesota are gray and smoggy. And in some places, the air quality warnings include the warning to stay inside. We wanted to better understand what's happening here and why, so we called Peter de Carlo, an associate professor in the Department of Environmental Health and Engineering at Johns Hopkins University Varsity. Good morning, professor. Good morning.",
* "labels": [
* {
* "relevance": 0.988274097442627,
* "label": "Home&Garden>IndoorEnvironmentalQuality"
* },
* {
* "relevance": 0.5821335911750793,
* "label": "NewsAndPolitics>Weather"
* },
* {
* "relevance": 0.0042327106930315495,
* "label": "MedicalHealth>DiseasesAndConditions>LungAndRespiratoryHealth"
* },
* {
* "relevance": 0.0033971222583204508,
* "label": "NewsAndPolitics>Disasters"
* },
* {
* "relevance": 0.002469958271831274,
* "label": "BusinessAndFinance>Business>GreenSolutions"
* },
* {
* "relevance": 0.0014376690378412604,
* "label": "MedicalHealth>DiseasesAndConditions>Cancer"
* },
* {
* "relevance": 0.0014294233405962586,
* "label": "Science>Environment"
* },
* {
* "relevance": 0.001234519761055708,
* "label": "Travel>TravelLocations>PolarTravel"
* },
* {
* "relevance": 0.0010231725173071027,
* "label": "MedicalHealth>DiseasesAndConditions>ColdAndFlu"
* },
* {
* "relevance": 0.0007445293595083058,
* "label": "BusinessAndFinance>Industries>PowerAndEnergyIndustry"
* }
* ],
* "timestamp": {
* "start": 250,
* "end": 28840
* }
* }
* ],
* "summary": {
* "NewsAndPolitics>Weather": 1,
* "Home&Garden>IndoorEnvironmentalQuality": 0.9043831825256348,
* "Science>Environment": 0.16117265820503235,
* "BusinessAndFinance>Industries>EnvironmentalServicesIndustry": 0.14393523335456848,
* "MedicalHealth>DiseasesAndConditions>LungAndRespiratoryHealth": 0.11401086300611496,
* "BusinessAndFinance>Business>GreenSolutions": 0.06348437070846558,
* "NewsAndPolitics>Disasters": 0.05041387677192688,
* "Travel>TravelLocations>PolarTravel": 0.01308488193899393,
* "HealthyLiving": 0.008222488686442375,
* "MedicalHealth>DiseasesAndConditions>ColdAndFlu": 0.0022315620444715023,
* "MedicalHealth>DiseasesAndConditions>HeartAndCardiovascularDiseases": 0.00213034451007843,
* "HealthyLiving>Wellness>SmokingCessation": 0.001540527562610805,
* "MedicalHealth>DiseasesAndConditions>Injuries": 0.0013950627762824297,
* "BusinessAndFinance>Industries>PowerAndEnergyIndustry": 0.0012570273829624057,
* "MedicalHealth>DiseasesAndConditions>Cancer": 0.001097781932912767,
* "MedicalHealth>DiseasesAndConditions>Allergies": 0.0010148967849090695,
* "MedicalHealth>DiseasesAndConditions>MentalHealth": 0.000717321818228811,
* "Style&Fashion>PersonalCare>DeodorantAndAntiperspirant": 0.0006022014422342181,
* "Technology&Computing>Computing>ComputerNetworking": 0.0005461975233629346,
* "MedicalHealth>DiseasesAndConditions>Injuries>FirstAid": 0.0004885646631009877
* }
* }
* ```
*/
export type TopicDetectionModelResult = {
/**
* An array of results for the Topic Detection model
*/
results: TopicDetectionResult[];
/**
* The status of the Topic Detection model. Either success, or unavailable in the rare case that the model failed.
*/
status: AudioIntelligenceModelStatus;
/**
* The overall relevance of topic to the entire audio file
*/
summary: {
[key: string]: number;
};
};
/**
* The result of the topic detection model
* @example
* ```js
* {
* "text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines from Maine to Maryland to Minnesota are gray and smoggy. And in some places, the air quality warnings include the warning to stay inside. We wanted to better understand what's happening here and why, so we called Peter de Carlo, an associate professor in the Department of Environmental Health and Engineering at Johns Hopkins University Varsity. Good morning, professor. Good morning.",
* "labels": [
* {
* "relevance": 0.988274097442627,
* "label": "Home&Garden>IndoorEnvironmentalQuality"
* },
* {
* "relevance": 0.5821335911750793,
* "label": "NewsAndPolitics>Weather"
* },
* {
* "relevance": 0.0042327106930315495,
* "label": "MedicalHealth>DiseasesAndConditions>LungAndRespiratoryHealth"
* },
* {
* "relevance": 0.0033971222583204508,
* "label": "NewsAndPolitics>Disasters"
* },
* {
* "relevance": 0.002469958271831274,
* "label": "BusinessAndFinance>Business>GreenSolutions"
* },
* {
* "relevance": 0.0014376690378412604,
* "label": "MedicalHealth>DiseasesAndConditions>Cancer"
* },
* {
* "relevance": 0.0014294233405962586,
* "label": "Science>Environment"
* },
* {
* "relevance": 0.001234519761055708,
* "label": "Travel>TravelLocations>PolarTravel"
* },
* {
* "relevance": 0.0010231725173071027,
* "label": "MedicalHealth>DiseasesAndConditions>ColdAndFlu"
* },
* {
* "relevance": 0.0007445293595083058,
* "label": "BusinessAndFinance>Industries>PowerAndEnergyIndustry"
* }
* ],
* "timestamp": {
* "start": 250,
* "end": 28840
* }
* }
* ```
*/
export type TopicDetectionResult = {
/**
* An array of detected topics in the text
*/
labels?: {
/**
* The IAB taxonomical label for the label of the detected topic, where > denotes supertopic/subtopic relationship
*/
label: string;
/**
* How relevant the detected topic is of a detected topic
*/
relevance: number;
}[];
/**
* The text in the transcript in which a detected topic occurs
*/
text: string;
timestamp?: Timestamp;
};
/**
* A transcript object
* @example
* ```js
* {
* "id": "9ea68fd3-f953-42c1-9742-976c447fb463",
* "speech_model": null,
* "language_model": "assemblyai_default",
* "acoustic_model": "assemblyai_default",
* "language_code": "en_us",
* "language_detection": true,
* "language_confidence_threshold": 0.7,
* "language_confidence": 0.9959,
* "status": "completed",
* "audio_url": "https://assembly.ai/wildfires.mp3",
* "text": "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines from Maine to Maryland to Minnesota are gray and smoggy. And in some places, the air quality warnings include the warning to stay inside. We wanted to better understand what's happening here and why, so we called Peter de Carlo, an associate professor in the Department of Environmental Health and Engineering at Johns Hopkins University Varsity. Good morning, professor. Good morning. What is it about the conditions right now that have caused this round of wildfires to affect so many people so far away? Well, there's a couple of things. The season has been pretty dry already. And then the fact that we're getting hit in the US. Is because there's a couple of weather systems that are essentially channeling the smoke from those Canadian wildfires through Pennsylvania into the Mid Atlantic and the Northeast and kind of just dropping the smoke there. So what is it in this haze that makes it harmful? And I'm assuming it is harmful. It is. The levels outside right now in Baltimore are considered unhealthy. And most of that is due to what's called particulate matter, which are tiny particles, microscopic smaller than the width of your hair that can get into your lungs and impact your respiratory system, your cardiovascular system, and even your neurological your brain. What makes this particularly harmful? Is it the volume of particulant? Is it something in particular? What is it exactly? Can you just drill down on that a little bit more? Yeah. So the concentration of particulate matter I was looking at some of the monitors that we have was reaching levels of what are, in science, big 150 micrograms per meter cubed, which is more than ten times what the annual average should be and about four times higher than what you're supposed to have on a 24 hours average. And so the concentrations of these particles in the air are just much, much higher than we typically see. And exposure to those high levels can lead to a host of health problems. And who is most vulnerable? I noticed that in New York City, for example, they're canceling outdoor activities. And so here it is in the early days of summer, and they have to keep all the kids inside. So who tends to be vulnerable in a situation like this? It's the youngest. So children, obviously, whose bodies are still developing. The elderly, who are their bodies are more in decline and they're more susceptible to the health impacts of breathing, the poor air quality. And then people who have preexisting health conditions, people with respiratory conditions or heart conditions can be triggered by high levels of air pollution. Could this get worse? That's a good question. In some areas, it's much worse than others. And it just depends on kind of where the smoke is concentrated. I think New York has some of the higher concentrations right now, but that's going to change as that air moves away from the New York area. But over the course of the next few days, we will see different areas being hit at different times with the highest concentrations. I was going to ask you about more fires start burning. I don't expect the concentrations to go up too much higher. I was going to ask you how and you started to answer this, but how much longer could this last? Or forgive me if I'm asking you to speculate, but what do you think? Well, I think the fires are going to burn for a little bit longer, but the key for us in the US. Is the weather system changing. And so right now, it's kind of the weather systems that are pulling that air into our mid Atlantic and Northeast region. As those weather systems change and shift, we'll see that smoke going elsewhere and not impact us in this region as much. And so I think that's going to be the defining factor. And I think the next couple of days we're going to see a shift in that weather pattern and start to push the smoke away from where we are. And finally, with the impacts of climate change, we are seeing more wildfires. Will we be seeing more of these kinds of wide ranging air quality consequences or circumstances? I mean, that is one of the predictions for climate change. Looking into the future, the fire season is starting earlier and lasting longer, and we're seeing more frequent fires. So, yeah, this is probably something that we'll be seeing more frequently. This tends to be much more of an issue in the Western US. So the eastern US. Getting hit right now is a little bit new. But yeah, I think with climate change moving forward, this is something that is going to happen more frequently. That's Peter De Carlo, associate professor in the Department of Environmental Health and Engineering at Johns Hopkins University. Sergeant Carlo, thanks so much for joining us and sharing this expertise with us. Thank you for having me.",
* "words": [
* {
* "text": "Smoke",
* "start": 250,
* "end": 650,
* "confidence": 0.97465,
* "speaker": null
* },
* {
* "text": "from",
* "start": 730,
* "end": 1022,
* "confidence": 0.99999,
* "speaker": null
* },
* {
* "text": "hundreds",
* "start": 1076,
* "end": 1418,
* "confidence": 0.99844,
* "speaker": null
* },
* {
* "text": "of",
* "start": 1434,
* "end": 1614,
* "confidence": 0.84,
* "speaker": null
* },
* {
* "text": "wildfires",
* "start": 1652,
* "end": 2346,
* "confidence": 0.89572,
* "speaker": null
* },
* {
* "text": "in",
* "start": 2378,
* "end": 2526,
* "confidence": 0.99994,
* "speaker": null
* },
* {
* "text": "Canada",
* "start": 2548,
* "end": 3130,
* "confidence": 0.93953,
* "speaker": null
* },
* {
* "text": "is",
* "start": 3210,
* "end": 3454,
* "confidence": 0.999,
* "speaker": null
* },
* {
* "text": "triggering",
* "start": 3492,
* "end": 3946,
* "confidence": 0.74794,
* "speaker": null
* },
* {