@saltcorn/large-language-model 0.9.11 → 0.9.12

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 (2) hide show
  1. package/generate.js +16 -1
  2. package/package.json +3 -2
package/generate.js CHANGED
@@ -24,6 +24,8 @@ const {
24
24
  } = require("ai");
25
25
  const { createOpenAI } = require("@ai-sdk/openai");
26
26
  const OpenAI = require("openai");
27
+ const { ElevenLabsClient } = require("@elevenlabs/elevenlabs-js");
28
+
27
29
  let ollamaMod;
28
30
  if (features.esm_plugins) ollamaMod = require("ollama");
29
31
 
@@ -121,7 +123,20 @@ const getAudioTranscription = async (
121
123
  { backend, apiKey, api_key, provider, ai_sdk_provider },
122
124
  opts
123
125
  ) => {
124
- switch (backend) {
126
+ switch (opts.backend || backend) {
127
+ case "ElevenLabs":
128
+ const transcription = await new ElevenLabsClient({
129
+ apiKey: opts?.api_key || api_key || apiKey,
130
+ }).speechToText.convert({
131
+ file: await (await File.findOne(opts.file)).get_contents(),
132
+ modelId: opts.model || "scribe_v2", // Model to use
133
+ tagAudioEvents: true, // Tag audio events like laughter, applause, etc.
134
+ languageCode: opts.languageCode || "eng", // Language of the audio file. If set to null, the model will detect the language automatically.
135
+ numSpeakers: opts.numSpeakers || null, // Language of the audio file. If set to null, the model will detect the language automatically.
136
+ diarize: !!opts.diarize, // Whether to annotate who is speaking
137
+ diarizationThreshold: opts.diarizationThreshold || null
138
+ });
139
+ return transcription;
125
140
  case "OpenAI":
126
141
  const client = new OpenAI({
127
142
  apiKey: opts?.api_key || api_key || apiKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/large-language-model",
3
- "version": "0.9.11",
3
+ "version": "0.9.12",
4
4
  "description": "Large language models and functionality for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -13,7 +13,8 @@
13
13
  "googleapis": "^144.0.0",
14
14
  "ai": "5.0.44",
15
15
  "@ai-sdk/openai": "2.0.30",
16
- "openai": "6.16.0"
16
+ "openai": "6.16.0",
17
+ "@elevenlabs/elevenlabs-js": "2.31.0"
17
18
  },
18
19
  "author": "Tom Nielsen",
19
20
  "license": "MIT",