@unboundcx/sdk 4.8.5 → 4.8.6
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/package.json +1 -1
- package/services/ai.js +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.6",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
package/services/ai.js
CHANGED
|
@@ -642,6 +642,32 @@ export class SpeechToTextService {
|
|
|
642
642
|
return result;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
/**
|
|
646
|
+
* Synchronously transcribe a stored audio file (batch STT).
|
|
647
|
+
* Counterpart to stream(): give it a storage file id, get the transcript
|
|
648
|
+
* back in the response (typically ~1-3s for voicemail-length audio).
|
|
649
|
+
*
|
|
650
|
+
* @param {Object} options
|
|
651
|
+
* @param {string} options.storageId - Storage file id of the audio (WAV by default).
|
|
652
|
+
* @param {string} [options.language] - Language hint (default 'en').
|
|
653
|
+
* @param {string} [options.encoding] - Audio encoding (default 'WAV').
|
|
654
|
+
* @returns {Promise<{transcription: string|null, language: string|null, duration: number|null}>}
|
|
655
|
+
*/
|
|
656
|
+
async file({ storageId, language, encoding } = {}) {
|
|
657
|
+
this.sdk.validateParams(
|
|
658
|
+
{ storageId, language, encoding },
|
|
659
|
+
{
|
|
660
|
+
storageId: { type: 'string', required: true },
|
|
661
|
+
language: { type: 'string', required: false },
|
|
662
|
+
encoding: { type: 'string', required: false },
|
|
663
|
+
},
|
|
664
|
+
);
|
|
665
|
+
const body = { storageId };
|
|
666
|
+
if (language !== undefined) body.language = language;
|
|
667
|
+
if (encoding !== undefined) body.encoding = encoding;
|
|
668
|
+
return await this.sdk._fetch('/ai/stt/file', 'POST', { body });
|
|
669
|
+
}
|
|
670
|
+
|
|
645
671
|
/**
|
|
646
672
|
* Create a real-time streaming transcription session
|
|
647
673
|
* Returns an EventEmitter-based stream for sending audio and receiving transcripts
|