Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): add AssemblyAI transcription options module

Richie McIlroyae3ceeec6ebf
diff --git a/apps/web/lib/assemblyai.ts b/apps/web/lib/assemblyai.ts
new file mode 100644
index 000000000..0a00797ec
--- /dev/null
+++ b/apps/web/lib/assemblyai.ts
@@ -0,0 +1,63 @@
+import {
+ AI_GENERATION_LANGUAGE_AUTO,
+ type AiGenerationLanguage,
+ type AiGenerationLanguageCode,
+} from "@cap/web-domain";
+
+export const ASSEMBLYAI_SPEECH_MODELS = [
+ "universal-3-5-pro",
+ "universal-2",
+] as const;
+
+export const ASSEMBLYAI_SUPPORTED_LANGUAGES = [
+ "en",
+ "es",
+ "fr",
+ "de",
+ "pt",
+ "it",
+ "nl",
+ "pl",
+ "ro",
+ "sk",
+ "ru",
+ "tr",
+ "ja",
+ "ko",
+ "zh",
+ "ar",
+ "hi",
+ "bn",
+ "ta",
+ "te",
+ "mr",
+ "gu",
+ "ur",
+ "fa",
+ "he",
+] as const satisfies readonly AiGenerationLanguageCode[];
+
+export function getAssemblyAITranscriptionOptions(
+ language: AiGenerationLanguage,
+) {
+ const baseOptions = {
+ speech_models: [...ASSEMBLYAI_SPEECH_MODELS],
+ format_text: true,
+ punctuate: true,
+ };
+
+ if (language === AI_GENERATION_LANGUAGE_AUTO) {
+ return {
+ ...baseOptions,
+ language_detection: true,
+ language_detection_options: {
+ expected_languages: [...ASSEMBLYAI_SUPPORTED_LANGUAGES],
+ },
+ };
+ }
+
+ return {
+ ...baseOptions,
+ language_code: language,
+ };
+}