assemblyai 4.5.0-beta.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +53 -9
  3. package/dist/assemblyai.streaming.umd.js +317 -0
  4. package/dist/assemblyai.streaming.umd.min.js +1 -0
  5. package/dist/assemblyai.umd.js +160 -12
  6. package/dist/assemblyai.umd.min.js +1 -1
  7. package/dist/browser.mjs +154 -11
  8. package/dist/bun.mjs +154 -11
  9. package/dist/deno.mjs +154 -11
  10. package/dist/exports/index.d.ts +2 -0
  11. package/dist/exports/streaming.d.ts +4 -0
  12. package/dist/index.cjs +160 -12
  13. package/dist/index.mjs +160 -12
  14. package/dist/node.cjs +154 -11
  15. package/dist/node.mjs +154 -11
  16. package/dist/polyfills/fetch/default.d.ts +1 -0
  17. package/dist/polyfills/fetch/workerd.d.ts +1 -0
  18. package/dist/services/base.d.ts +1 -0
  19. package/dist/services/lemur/index.d.ts +8 -1
  20. package/dist/services/realtime/service.d.ts +60 -0
  21. package/dist/services/transcripts/index.d.ts +16 -3
  22. package/dist/streaming.browser.mjs +268 -0
  23. package/dist/streaming.cjs +306 -0
  24. package/dist/streaming.mjs +303 -0
  25. package/dist/types/index.d.ts +7 -0
  26. package/dist/types/openapi.generated.d.ts +75 -29
  27. package/dist/types/services/index.d.ts +7 -0
  28. package/dist/types/transcripts/index.d.ts +9 -0
  29. package/dist/utils/userAgent.d.ts +2 -0
  30. package/dist/workerd.mjs +751 -0
  31. package/docs/reference-types-from-js.md +27 -0
  32. package/package.json +57 -25
  33. package/src/exports/index.ts +2 -0
  34. package/src/exports/streaming.ts +4 -0
  35. package/src/polyfills/fetch/default.ts +3 -0
  36. package/src/polyfills/fetch/workerd.ts +1 -0
  37. package/src/services/base.ts +27 -7
  38. package/src/services/files/index.ts +19 -2
  39. package/src/services/index.ts +2 -1
  40. package/src/services/lemur/index.ts +12 -0
  41. package/src/services/realtime/service.ts +65 -0
  42. package/src/services/transcripts/index.ts +41 -4
  43. package/src/types/index.ts +9 -0
  44. package/src/types/openapi.generated.ts +224 -48
  45. package/src/types/services/index.ts +8 -0
  46. package/src/types/transcripts/index.ts +10 -0
  47. package/src/utils/path.ts +1 -0
  48. package/src/utils/userAgent.ts +51 -0
@@ -497,35 +497,50 @@ export type Entity = {
497
497
  * The type of entity for the detected entity
498
498
  */
499
499
  export type EntityType =
500
+ | "account_number"
500
501
  | "banking_information"
501
502
  | "blood_type"
502
503
  | "credit_card_cvv"
503
504
  | "credit_card_expiration"
504
505
  | "credit_card_number"
505
506
  | "date"
507
+ | "date_interval"
506
508
  | "date_of_birth"
507
509
  | "drivers_license"
508
510
  | "drug"
511
+ | "duration"
509
512
  | "email_address"
510
513
  | "event"
514
+ | "filename"
515
+ | "gender_sexuality"
516
+ | "healthcare_number"
511
517
  | "injury"
518
+ | "ip_address"
512
519
  | "language"
513
520
  | "location"
521
+ | "marital_status"
514
522
  | "medical_condition"
515
523
  | "medical_process"
516
524
  | "money_amount"
517
525
  | "nationality"
526
+ | "number_sequence"
518
527
  | "occupation"
519
528
  | "organization"
529
+ | "passport_number"
520
530
  | "password"
521
531
  | "person_age"
522
532
  | "person_name"
523
533
  | "phone_number"
534
+ | "physical_attribute"
524
535
  | "political_affiliation"
525
536
  | "religion"
537
+ | "statistics"
526
538
  | "time"
527
539
  | "url"
528
- | "us_social_security_number";
540
+ | "us_social_security_number"
541
+ | "username"
542
+ | "vehicle_id"
543
+ | "zodiac_sign";
529
544
 
530
545
  /**
531
546
  * @example
@@ -573,7 +588,11 @@ export type LemurActionItemsParams = LemurBaseParams & {
573
588
  * ```js
574
589
  * {
575
590
  * "request_id": "5"e1b27c2-691f-4414-8bc5-f14678442f9e",
576
- * "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"
591
+ * "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",
592
+ * "usage": {
593
+ * "input_tokens": 27,
594
+ * "output_tokens": 3
595
+ * }
577
596
  * }
578
597
  * ```
579
598
  */
@@ -613,7 +632,6 @@ export type LemurBaseParams = {
613
632
  >;
614
633
  /**
615
634
  * The model that is used for the final prompt after compression is performed.
616
- * Defaults to "default".
617
635
  *
618
636
  * @defaultValue "default
619
637
  */
@@ -644,7 +662,11 @@ export type LemurBaseParams = {
644
662
  * @example
645
663
  * ```js
646
664
  * {
647
- * "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e"
665
+ * "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
666
+ * "usage": {
667
+ * "input_tokens": 27,
668
+ * "output_tokens": 3
669
+ * }
648
670
  * }
649
671
  * ```
650
672
  */
@@ -653,6 +675,10 @@ export type LemurBaseResponse = {
653
675
  * The ID of the LeMUR request
654
676
  */
655
677
  request_id: string;
678
+ /**
679
+ * The usage numbers for the LeMUR request
680
+ */
681
+ usage: LemurUsage;
656
682
  };
657
683
 
658
684
  /**
@@ -660,10 +686,16 @@ export type LemurBaseResponse = {
660
686
  *
661
687
  */
662
688
  export type LemurModel =
689
+ | "anthropic/claude-3-5-sonnet"
690
+ | "anthropic/claude-3-opus"
691
+ | "anthropic/claude-3-haiku"
692
+ | "anthropic/claude-3-sonnet"
693
+ | "anthropic/claude-2-1"
694
+ | "anthropic/claude-2"
663
695
  | "default"
696
+ | "anthropic/claude-instant-1-2"
664
697
  | "basic"
665
- | "assemblyai/mistral-7b"
666
- | "anthropic/claude-2-1";
698
+ | "assemblyai/mistral-7b";
667
699
 
668
700
  /**
669
701
  * @example
@@ -773,7 +805,11 @@ export type LemurQuestionAnswerParams = LemurBaseParams & {
773
805
  * "answer": "yes",
774
806
  * "question": "Is global warming affecting wildfires?"
775
807
  * }
776
- * ]
808
+ * ],
809
+ * "usage": {
810
+ * "input_tokens": 27,
811
+ * "output_tokens": 3
812
+ * }
777
813
  * }
778
814
  * ```
779
815
  */
@@ -784,12 +820,18 @@ export type LemurQuestionAnswerResponse = LemurBaseResponse & {
784
820
  response: LemurQuestionAnswer[];
785
821
  };
786
822
 
823
+ export type LemurResponse =
824
+ | LemurTaskResponse
825
+ | LemurSummaryResponse
826
+ | LemurQuestionAnswerResponse
827
+ | LemurActionItemsResponse;
828
+
787
829
  /**
788
830
  * @example
789
831
  * ```js
790
832
  * {
791
833
  * "transcript_ids": [
792
- * "64nygnr62k-405c-4ae8-8a6b-d90b40ff3cce"
834
+ * "47b95ba5-8889-44d8-bc80-5de38306e582"
793
835
  * ],
794
836
  * "context": "This is an interview about wildfires.",
795
837
  * "final_model": "default",
@@ -810,7 +852,11 @@ export type LemurSummaryParams = LemurBaseParams & {
810
852
  * ```js
811
853
  * {
812
854
  * "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
813
- * "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"
855
+ * "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",
856
+ * "usage": {
857
+ * "input_tokens": 27,
858
+ * "output_tokens": 3
859
+ * }
814
860
  * }
815
861
  * ```
816
862
  */
@@ -848,7 +894,11 @@ export type LemurTaskParams = {
848
894
  * ```js
849
895
  * {
850
896
  * "request_id": "5e1b27c2-691f-4414-8bc5-f14678442f9e",
851
- * "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"
897
+ * "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",
898
+ * "usage": {
899
+ * "input_tokens": 27,
900
+ * "output_tokens": 3
901
+ * }
852
902
  * }
853
903
  * ```
854
904
  */
@@ -859,6 +909,20 @@ export type LemurTaskResponse = {
859
909
  response: string;
860
910
  } & LemurBaseResponse;
861
911
 
912
+ /**
913
+ * The usage numbers for the LeMUR request
914
+ */
915
+ export type LemurUsage = {
916
+ /**
917
+ * The number of input tokens used by the model
918
+ */
919
+ input_tokens: number;
920
+ /**
921
+ * The number of output tokens generated by the model
922
+ */
923
+ output_tokens: number;
924
+ };
925
+
862
926
  /**
863
927
  * @example
864
928
  * ```js
@@ -901,7 +965,6 @@ export type ListTranscriptParams = {
901
965
  };
902
966
 
903
967
  /**
904
- * Details of the transcript page.
905
968
  * Details of the transcript page. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
906
969
  * @example
907
970
  * ```js
@@ -924,12 +987,10 @@ export type PageDetails = {
924
987
  */
925
988
  limit: number;
926
989
  /**
927
- * The URL to the next page of transcripts
928
990
  * The URL to the next page of transcripts. The next URL always points to a page with newer transcripts.
929
991
  */
930
992
  next_url: string | null;
931
993
  /**
932
- * The URL to the previous page of transcripts
933
994
  * The URL to the next page of transcripts. The previous URL always points to a page with older transcripts.
934
995
  */
935
996
  prev_url: string | null;
@@ -1023,34 +1084,54 @@ export type ParagraphsResponse = {
1023
1084
  paragraphs: TranscriptParagraph[];
1024
1085
  };
1025
1086
 
1087
+ /**
1088
+ * The type of PII to redact
1089
+ */
1026
1090
  export type PiiPolicy =
1027
- | "medical_process"
1028
- | "medical_condition"
1091
+ | "account_number"
1092
+ | "banking_information"
1029
1093
  | "blood_type"
1030
- | "drug"
1031
- | "injury"
1032
- | "number_sequence"
1033
- | "email_address"
1034
- | "date_of_birth"
1035
- | "phone_number"
1036
- | "us_social_security_number"
1037
- | "credit_card_number"
1038
- | "credit_card_expiration"
1039
1094
  | "credit_card_cvv"
1095
+ | "credit_card_expiration"
1096
+ | "credit_card_number"
1040
1097
  | "date"
1041
- | "nationality"
1098
+ | "date_interval"
1099
+ | "date_of_birth"
1100
+ | "drivers_license"
1101
+ | "drug"
1102
+ | "duration"
1103
+ | "email_address"
1042
1104
  | "event"
1105
+ | "filename"
1106
+ | "gender_sexuality"
1107
+ | "healthcare_number"
1108
+ | "injury"
1109
+ | "ip_address"
1043
1110
  | "language"
1044
1111
  | "location"
1112
+ | "marital_status"
1113
+ | "medical_condition"
1114
+ | "medical_process"
1045
1115
  | "money_amount"
1046
- | "person_name"
1047
- | "person_age"
1116
+ | "nationality"
1117
+ | "number_sequence"
1118
+ | "occupation"
1048
1119
  | "organization"
1120
+ | "passport_number"
1121
+ | "password"
1122
+ | "person_age"
1123
+ | "person_name"
1124
+ | "phone_number"
1125
+ | "physical_attribute"
1049
1126
  | "political_affiliation"
1050
- | "occupation"
1051
1127
  | "religion"
1052
- | "drivers_license"
1053
- | "banking_information";
1128
+ | "statistics"
1129
+ | "time"
1130
+ | "url"
1131
+ | "us_social_security_number"
1132
+ | "username"
1133
+ | "vehicle_id"
1134
+ | "zodiac_sign";
1054
1135
 
1055
1136
  /**
1056
1137
  * @example
@@ -1092,6 +1173,11 @@ export type RealtimeTemporaryTokenResponse = {
1092
1173
  token: string;
1093
1174
  };
1094
1175
 
1176
+ /**
1177
+ * The notification when the redacted audio is ready.
1178
+ */
1179
+ export type RedactedAudioNotification = RedactedAudioResponse;
1180
+
1095
1181
  /**
1096
1182
  * @example
1097
1183
  * ```js
@@ -1234,7 +1320,7 @@ export type SentencesResponse = {
1234
1320
  export type Sentiment = "POSITIVE" | "NEUTRAL" | "NEGATIVE";
1235
1321
 
1236
1322
  /**
1237
- * The result of the sentiment analysis model
1323
+ * The result of the Sentiment Analysis model
1238
1324
  * @example
1239
1325
  * ```js
1240
1326
  * {
@@ -2239,7 +2325,7 @@ export type Transcript = {
2239
2325
  auto_highlights: boolean;
2240
2326
  /**
2241
2327
  * An array of results for the Key Phrases model, if it is enabled.
2242
- * See {@link https://www.assemblyai.com/docs/models/key-phrases | Key phrases } for more information.
2328
+ * See {@link https://www.assemblyai.com/docs/models/key-phrases | Key Phrases } for more information.
2243
2329
  */
2244
2330
  auto_highlights_result?: AutoHighlightsResult | null;
2245
2331
  /**
@@ -2361,7 +2447,7 @@ export type Transcript = {
2361
2447
  sentiment_analysis?: boolean | null;
2362
2448
  /**
2363
2449
  * An array of results for the Sentiment Analysis model, if it is enabled.
2364
- * See {@link https://www.assemblyai.com/docs/models/sentiment-analysis | Sentiment analysis } for more information.
2450
+ * See {@link https://www.assemblyai.com/docs/models/sentiment-analysis | Sentiment Analysis } for more information.
2365
2451
  */
2366
2452
  sentiment_analysis_results?: SentimentAnalysisResult[] | null;
2367
2453
  /**
@@ -2430,15 +2516,17 @@ export type Transcript = {
2430
2516
  */
2431
2517
  webhook_auth: boolean;
2432
2518
  /**
2433
- * The header name which should be sent back with webhook calls
2519
+ * The header name to be sent with the transcript completed or failed webhook requests
2434
2520
  */
2435
2521
  webhook_auth_header_name?: string | null;
2436
2522
  /**
2437
- * The status code we received from your server when delivering your webhook, if a webhook URL was provided
2523
+ * The status code we received from your server when delivering the transcript completed or failed webhook request, if a webhook URL was provided
2438
2524
  */
2439
2525
  webhook_status_code?: number | null;
2440
2526
  /**
2441
- * The URL to which we send webhooks upon trancription completion
2527
+ * The URL to which we send webhook requests.
2528
+ * We sends two different types of webhook requests.
2529
+ * One request when a transcript is completed or failed, and one request when the redacted audio is ready if redact_pii_audio is enabled.
2442
2530
  */
2443
2531
  webhook_url?: string | null;
2444
2532
  /**
@@ -2497,19 +2585,100 @@ export type TranscriptLanguageCode =
2497
2585
  | "it"
2498
2586
  | "pt"
2499
2587
  | "nl"
2500
- | "hi"
2501
- | "ja"
2588
+ | "af"
2589
+ | "sq"
2590
+ | "am"
2591
+ | "ar"
2592
+ | "hy"
2593
+ | "as"
2594
+ | "az"
2595
+ | "ba"
2596
+ | "eu"
2597
+ | "be"
2598
+ | "bn"
2599
+ | "bs"
2600
+ | "br"
2601
+ | "bg"
2602
+ | "my"
2603
+ | "ca"
2502
2604
  | "zh"
2605
+ | "hr"
2606
+ | "cs"
2607
+ | "da"
2608
+ | "et"
2609
+ | "fo"
2503
2610
  | "fi"
2611
+ | "gl"
2612
+ | "ka"
2613
+ | "el"
2614
+ | "gu"
2615
+ | "ht"
2616
+ | "ha"
2617
+ | "haw"
2618
+ | "he"
2619
+ | "hi"
2620
+ | "hu"
2621
+ | "is"
2622
+ | "id"
2623
+ | "ja"
2624
+ | "jw"
2625
+ | "kn"
2626
+ | "kk"
2627
+ | "km"
2504
2628
  | "ko"
2629
+ | "lo"
2630
+ | "la"
2631
+ | "lv"
2632
+ | "ln"
2633
+ | "lt"
2634
+ | "lb"
2635
+ | "mk"
2636
+ | "mg"
2637
+ | "ms"
2638
+ | "ml"
2639
+ | "mt"
2640
+ | "mi"
2641
+ | "mr"
2642
+ | "mn"
2643
+ | "ne"
2644
+ | "no"
2645
+ | "nn"
2646
+ | "oc"
2647
+ | "pa"
2648
+ | "ps"
2649
+ | "fa"
2505
2650
  | "pl"
2651
+ | "ro"
2506
2652
  | "ru"
2653
+ | "sa"
2654
+ | "sr"
2655
+ | "sn"
2656
+ | "sd"
2657
+ | "si"
2658
+ | "sk"
2659
+ | "sl"
2660
+ | "so"
2661
+ | "su"
2662
+ | "sw"
2663
+ | "sv"
2664
+ | "tl"
2665
+ | "tg"
2666
+ | "ta"
2667
+ | "tt"
2668
+ | "te"
2669
+ | "th"
2670
+ | "bo"
2507
2671
  | "tr"
2672
+ | "tk"
2508
2673
  | "uk"
2509
- | "vi";
2674
+ | "ur"
2675
+ | "uz"
2676
+ | "vi"
2677
+ | "cy"
2678
+ | "yi"
2679
+ | "yo";
2510
2680
 
2511
2681
  /**
2512
- * A list of transcripts
2513
2682
  * A list of transcripts. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
2514
2683
  * @example
2515
2684
  * ```js
@@ -2649,7 +2818,7 @@ export type TranscriptOptionalParams = {
2649
2818
  */
2650
2819
  auto_chapters?: boolean;
2651
2820
  /**
2652
- * Whether Key Phrases is enabled, either true or false
2821
+ * Enable Key Phrases, either true or false
2653
2822
  */
2654
2823
  auto_highlights?: boolean;
2655
2824
  /**
@@ -2661,7 +2830,7 @@ export type TranscriptOptionalParams = {
2661
2830
  */
2662
2831
  content_safety?: boolean;
2663
2832
  /**
2664
- * The confidence threshold for content moderation. Values must be between 25 and 100.
2833
+ * The confidence threshold for the Content Moderation model. Values must be between 25 and 100.
2665
2834
  */
2666
2835
  content_safety_confidence?: number;
2667
2836
  /**
@@ -2669,7 +2838,7 @@ export type TranscriptOptionalParams = {
2669
2838
  */
2670
2839
  custom_spelling?: TranscriptCustomSpelling[];
2671
2840
  /**
2672
- * Whether custom topics is enabled, either true or false
2841
+ * Enable custom topics, either true or false
2673
2842
  */
2674
2843
  custom_topics?: boolean;
2675
2844
  /**
@@ -2702,7 +2871,7 @@ export type TranscriptOptionalParams = {
2702
2871
  */
2703
2872
  language_code?: LiteralUnion<TranscriptLanguageCode, string> | null;
2704
2873
  /**
2705
- * Whether {@link https://www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection | Automatic language detection } was enabled in the transcription request, either true or false.
2874
+ * Enable {@link https://www.assemblyai.com/docs/models/speech-recognition#automatic-language-detection | Automatic language detection }, either true or false.
2706
2875
  */
2707
2876
  language_detection?: boolean;
2708
2877
  /**
@@ -2770,21 +2939,21 @@ export type TranscriptOptionalParams = {
2770
2939
  */
2771
2940
  summary_type?: SummaryType;
2772
2941
  /**
2773
- * The list of custom topics provided, if custom topics is enabled
2942
+ * The list of custom topics
2774
2943
  */
2775
2944
  topics?: string[];
2776
2945
  /**
2777
- * The header name which should be sent back with webhook calls
2946
+ * The header name to be sent with the transcript completed or failed webhook requests
2778
2947
  * @defaultValue null
2779
2948
  */
2780
2949
  webhook_auth_header_name?: string | null;
2781
2950
  /**
2782
- * Specify a header name and value to send back with a webhook call for added security
2951
+ * The header value to send back with the transcript completed or failed webhook requests for added security
2783
2952
  * @defaultValue null
2784
2953
  */
2785
2954
  webhook_auth_header_value?: string | null;
2786
2955
  /**
2787
- * The URL to which AssemblyAI send webhooks upon trancription completion
2956
+ * The URL to which we send webhook requests. We sends two different types of webhook requests. One request when a transcript is completed or failed, and one request when the redacted audio is ready if redact_pii_audio is enabled.
2788
2957
  */
2789
2958
  webhook_url?: string;
2790
2959
  /**
@@ -3135,6 +3304,13 @@ export type TranscriptUtterance = {
3135
3304
  words: TranscriptWord[];
3136
3305
  };
3137
3306
 
3307
+ /**
3308
+ * The notifications sent to the webhook URL.
3309
+ */
3310
+ export type TranscriptWebhookNotification =
3311
+ | TranscriptReadyNotification
3312
+ | RedactedAudioNotification;
3313
+
3138
3314
  /**
3139
3315
  * @example
3140
3316
  * ```js
@@ -1,6 +1,14 @@
1
+ import { UserAgent } from "..";
2
+
1
3
  type BaseServiceParams = {
2
4
  apiKey: string;
3
5
  baseUrl?: string;
6
+ /**
7
+ * The AssemblyAI user agent to use for requests.
8
+ * The provided components will be merged into the default AssemblyAI user agent.
9
+ * If `false`, the AssemblyAI user agent will be removed.
10
+ */
11
+ userAgent?: UserAgent | false;
4
12
  };
5
13
 
6
14
  export type { BaseServiceParams };
@@ -54,3 +54,13 @@ export type SubmitParams = TranscribeParams;
54
54
  * The options to transcribe an audio file, including polling options.
55
55
  */
56
56
  export type TranscribeOptions = PollingOptions;
57
+
58
+ /**
59
+ * The PII redacted audio file, transmitted over the network.
60
+ */
61
+ export type RedactedAudioFile = {
62
+ arrayBuffer: () => Promise<ArrayBuffer>;
63
+ blob: () => Promise<Blob>;
64
+ body: ReadableStream<Uint8Array> | null;
65
+ bodyUsed: boolean;
66
+ };
package/src/utils/path.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export function getPath(path: string) {
2
2
  if (path.startsWith("http")) return null;
3
3
  if (path.startsWith("https")) return null;
4
+ if (path.startsWith("data:")) return null;
4
5
  if (path.startsWith("file://")) return path.substring(7);
5
6
  if (path.startsWith("file:")) return path.substring(5);
6
7
  return path;
@@ -0,0 +1,51 @@
1
+ import { UserAgent } from "../types";
2
+
3
+ export const buildUserAgent = (userAgent: UserAgent | false) =>
4
+ defaultUserAgentString +
5
+ (userAgent === false
6
+ ? ""
7
+ : " AssemblyAI/1.0 (" +
8
+ Object.entries({ ...defaultUserAgent, ...userAgent })
9
+ .map(([key, item]) =>
10
+ item ? `${key}=${item.name}/${item.version}` : "",
11
+ )
12
+ .join(" ") +
13
+ ")");
14
+
15
+ let defaultUserAgentString = "";
16
+ if (typeof navigator !== "undefined" && navigator.userAgent) {
17
+ defaultUserAgentString += navigator.userAgent;
18
+ }
19
+
20
+ const defaultUserAgent: UserAgent = {
21
+ sdk: { name: "JavaScript", version: "__SDK_VERSION__" },
22
+ };
23
+
24
+ if (typeof process !== "undefined") {
25
+ if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
26
+ defaultUserAgent.runtime_env = {
27
+ name: "Node",
28
+ version: process.versions.node,
29
+ };
30
+ }
31
+ if (process.versions.bun && defaultUserAgentString.indexOf("Bun") === -1) {
32
+ defaultUserAgent.runtime_env = {
33
+ name: "Bun",
34
+ version: process.versions.bun,
35
+ };
36
+ }
37
+ }
38
+
39
+ declare const Deno:
40
+ | {
41
+ version: {
42
+ deno: string;
43
+ };
44
+ }
45
+ | undefined;
46
+
47
+ if (typeof Deno !== "undefined") {
48
+ if (process.versions.bun && defaultUserAgentString.indexOf("Deno") === -1) {
49
+ defaultUserAgent.runtime_env = { name: "Deno", version: Deno.version.deno };
50
+ }
51
+ }