@memberjunction/ai-openai 2.34.2 → 2.35.1
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models/tts.d.ts +12 -0
- package/dist/models/tts.d.ts.map +1 -0
- package/dist/models/tts.js +70 -0
- package/dist/models/tts.js.map +1 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./models/openAI"), exports);
|
|
18
18
|
__exportStar(require("./models/openAIEmbedding"), exports);
|
|
19
19
|
__exportStar(require("./models/embeddingModels.types"), exports);
|
|
20
|
+
__exportStar(require("./models/tts"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,2DAAyC;AACzC,iEAA+C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,2DAAyC;AACzC,iEAA+C;AAC/C,+CAA6B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseAudioGenerator, TextToSpeechParams, SpeechResult, SpeechToTextParams, VoiceInfo, AudioModel, PronounciationDictionary } from "@memberjunction/ai";
|
|
2
|
+
export declare class OpenAIAudioGenerator extends BaseAudioGenerator {
|
|
3
|
+
private _openAI;
|
|
4
|
+
constructor(apiKey: string);
|
|
5
|
+
CreateSpeech(params: TextToSpeechParams): Promise<SpeechResult>;
|
|
6
|
+
SpeechToText(params: SpeechToTextParams): Promise<SpeechResult>;
|
|
7
|
+
GetVoices(): Promise<VoiceInfo[]>;
|
|
8
|
+
GetModels(): Promise<AudioModel[]>;
|
|
9
|
+
GetPronounciationDictionaries(): Promise<PronounciationDictionary[]>;
|
|
10
|
+
GetSupportedMethods(): Promise<string[]>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=tts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tts.d.ts","sourceRoot":"","sources":["../../src/models/tts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,YAAY,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAG/J,qBACa,oBAAqB,SAAQ,kBAAkB;IACxD,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,MAAM;IAKb,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAiB/D,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAI/D,SAAS,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAWjC,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAclC,6BAA6B,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAIpE,mBAAmB;CAGnC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.OpenAIAudioGenerator = void 0;
|
|
10
|
+
const global_1 = require("@memberjunction/global");
|
|
11
|
+
const ai_1 = require("@memberjunction/ai");
|
|
12
|
+
const openai_1 = require("openai");
|
|
13
|
+
let OpenAIAudioGenerator = class OpenAIAudioGenerator extends ai_1.BaseAudioGenerator {
|
|
14
|
+
constructor(apiKey) {
|
|
15
|
+
super(apiKey);
|
|
16
|
+
this._openAI = new openai_1.OpenAI({ apiKey: apiKey });
|
|
17
|
+
}
|
|
18
|
+
async CreateSpeech(params) {
|
|
19
|
+
const speechResult = new ai_1.SpeechResult();
|
|
20
|
+
const audio = await this._openAI.audio.speech.create({
|
|
21
|
+
model: params.model_id || (await this.GetModels())[0].id,
|
|
22
|
+
voice: params.voice || (await this.GetVoices())[0].id,
|
|
23
|
+
input: params.text,
|
|
24
|
+
instructions: params.instructions || "Speak in a cheerful and positive tone"
|
|
25
|
+
});
|
|
26
|
+
const arrayBuffer = await audio.arrayBuffer();
|
|
27
|
+
const audioBuffer = Buffer.from(arrayBuffer);
|
|
28
|
+
speechResult.data = audioBuffer;
|
|
29
|
+
speechResult.success = true;
|
|
30
|
+
speechResult.content = audioBuffer.toString('base64');
|
|
31
|
+
return speechResult;
|
|
32
|
+
}
|
|
33
|
+
async SpeechToText(params) {
|
|
34
|
+
throw new Error("Method not implemented.");
|
|
35
|
+
}
|
|
36
|
+
async GetVoices() {
|
|
37
|
+
return [
|
|
38
|
+
{ id: "alloy", name: "Alloy" },
|
|
39
|
+
{ id: "echo", name: "Echo" },
|
|
40
|
+
{ id: "fable", name: "Fable" },
|
|
41
|
+
{ id: "onyx", name: "Onyx" },
|
|
42
|
+
{ id: "nova", name: "Nova" },
|
|
43
|
+
{ id: "shimmer", name: "Shimmer" }
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
async GetModels() {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
id: "gpt-4o-mini-tts",
|
|
50
|
+
name: "GPT-4o Mini TTS",
|
|
51
|
+
supportsTextToSpeech: true,
|
|
52
|
+
supportsVoiceConversion: false,
|
|
53
|
+
supportsStyle: false,
|
|
54
|
+
supportsSpeakerBoost: false,
|
|
55
|
+
supportsFineTuning: false
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
async GetPronounciationDictionaries() {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
async GetSupportedMethods() {
|
|
63
|
+
return ["CreateSpeech", "GetVoices", "GetModels"];
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.OpenAIAudioGenerator = OpenAIAudioGenerator;
|
|
67
|
+
exports.OpenAIAudioGenerator = OpenAIAudioGenerator = __decorate([
|
|
68
|
+
(0, global_1.RegisterClass)(ai_1.BaseAudioGenerator, "OpenAIAudioGenerator")
|
|
69
|
+
], OpenAIAudioGenerator);
|
|
70
|
+
//# sourceMappingURL=tts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tts.js","sourceRoot":"","sources":["../../src/models/tts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAuD;AACvD,2CAA+J;AAC/J,mCAAgC;AAGzB,IAAM,oBAAoB,GA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EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;YAC5B,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;YAC9B,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;YAC5B,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;YAC5B,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;SACrC,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,SAAS;QAClB,OAAO;YACH;gBACI,EAAE,EAAE,iBAAiB;gBACrB,IAAI,EAAE,iBAAiB;gBACvB,oBAAoB,EAAE,IAAI;gBAC1B,uBAAuB,EAAE,KAAK;gBAC9B,aAAa,EAAE,KAAK;gBACpB,oBAAoB,EAAE,KAAK;gBAC3B,kBAAkB,EAAE,KAAK;aAC5B;SACJ,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,6BAA6B;QACtC,OAAO,EAAE,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,mBAAmB;QAC5B,OAAO,CAAC,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;CACJ,CAAA;AA7DY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,sBAAa,EAAC,uBAAkB,EAAE,sBAAsB,CAAC;GAC7C,oBAAoB,CA6DhC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ai-openai",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.35.1",
|
|
4
4
|
"description": "MemberJunction Wrapper for OpenAI AI Models",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"typescript": "^5.4.5"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@memberjunction/ai": "2.
|
|
23
|
-
"@memberjunction/global": "2.
|
|
24
|
-
"openai": "4.
|
|
22
|
+
"@memberjunction/ai": "2.35.1",
|
|
23
|
+
"@memberjunction/global": "2.35.1",
|
|
24
|
+
"openai": "4.96.0"
|
|
25
25
|
}
|
|
26
26
|
}
|