@crewdle/mist-connector-openai 1.0.12 → 1.0.13

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.
@@ -14,7 +14,20 @@ export class OpenAISpeechConnector {
14
14
  instructions,
15
15
  response_format: 'pcm',
16
16
  });
17
- return response.arrayBuffer();
17
+ if (!response.body) {
18
+ throw new Error('No response body');
19
+ }
20
+ if (response.body instanceof ReadableStream) {
21
+ return response.body;
22
+ }
23
+ const audio = response.body;
24
+ return new ReadableStream({
25
+ start(controller) {
26
+ audio.on('data', (chunk) => controller.enqueue(chunk));
27
+ audio.on('end', () => controller.close());
28
+ audio.on('error', (err) => controller.error(err));
29
+ }
30
+ });
18
31
  }
19
32
  getEngineType() {
20
33
  return 'openai';
@@ -2,6 +2,6 @@ import { GenerativeAIEngineType, IGenerativeAISpeechConnector } from '@crewdle/w
2
2
  export declare class OpenAISpeechConnector implements IGenerativeAISpeechConnector {
3
3
  private client;
4
4
  constructor(apiKey: string);
5
- speak(model: string, text: string, voice: string, instructions?: string): Promise<ArrayBuffer>;
5
+ speak(model: string, text: string, voice: string, instructions?: string): Promise<ReadableStream>;
6
6
  getEngineType(): GenerativeAIEngineType;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewdle/mist-connector-openai",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "dist/"
16
16
  ],
17
17
  "devDependencies": {
18
- "@crewdle/web-sdk-types": "^1.0.44",
18
+ "@crewdle/web-sdk-types": "^1.0.46",
19
19
  "@types/node": "^22.13.9",
20
20
  "typescript": "^5.8.2"
21
21
  },