mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-02-14 18:30:59 +00:00
Compare commits
1 Commits
v0.9.6-rc2
...
fix/tts-st
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8879d8e3e5 |
@@ -59,10 +59,13 @@ class TtsTask extends Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setTtsStreamingChannelVars(vendor, language, voice, credentials, ep) {
|
async setTtsStreamingChannelVars(vendor, language, voice, credentials, ep) {
|
||||||
const {api_key, model_id, cartesia_model_id, cartesia_voice_id} = credentials;
|
const {api_key, model_id} = credentials;
|
||||||
const {stability, similarity_boost, use_speaker_boost, style} = this.options;
|
const {stability, similarity_boost, use_speaker_boost, style} = this.options;
|
||||||
let obj;
|
let obj;
|
||||||
|
|
||||||
|
this.logger.debug({credentials},
|
||||||
|
`setTtsStreamingChannelVars: vendor: ${vendor}, language: ${language}, voice: ${voice}`);
|
||||||
|
|
||||||
switch (vendor) {
|
switch (vendor) {
|
||||||
case 'deepgram':
|
case 'deepgram':
|
||||||
obj = {
|
obj = {
|
||||||
@@ -73,8 +76,8 @@ class TtsTask extends Task {
|
|||||||
case 'cartesia':
|
case 'cartesia':
|
||||||
obj = {
|
obj = {
|
||||||
CARTESIA_API_KEY: api_key,
|
CARTESIA_API_KEY: api_key,
|
||||||
CARTESIA_TTS_STREAMING_MODEL_ID: cartesia_model_id,
|
CARTESIA_TTS_STREAMING_MODEL_ID: model_id,
|
||||||
CARTESIA_TTS_STREAMING_VOICE_ID: cartesia_voice_id,
|
CARTESIA_TTS_STREAMING_VOICE_ID: voice,
|
||||||
CARTESIA_TTS_STREAMING_LANGUAGE: language || 'en',
|
CARTESIA_TTS_STREAMING_LANGUAGE: language || 'en',
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ class TtsStreamingBuffer extends Emitter {
|
|||||||
return {status: 'failed', reason: `connection to ${this.vendor} failed`};
|
return {status: 'failed', reason: `connection to ${this.vendor} failed`};
|
||||||
}
|
}
|
||||||
|
|
||||||
const starting = this.tokens === '';
|
|
||||||
const displayedTokens = tokens.length <= 40 ? tokens : tokens.substring(0, 40);
|
const displayedTokens = tokens.length <= 40 ? tokens : tokens.substring(0, 40);
|
||||||
const totalLength = tokens.length;
|
const totalLength = tokens.length;
|
||||||
|
|
||||||
@@ -127,14 +126,14 @@ class TtsStreamingBuffer extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`TtsStreamingBuffer:bufferTokens "${displayedTokens}" (length: ${totalLength}), starting? ${starting}`
|
`TtsStreamingBuffer:bufferTokens "${displayedTokens}" (length: ${totalLength}), starting? ${this.isEmpty}`
|
||||||
);
|
);
|
||||||
this.tokens += (tokens || '');
|
this.tokens += (tokens || '');
|
||||||
|
|
||||||
const leftoverTokens = await this._feedTokens();
|
const leftoverTokens = await this._feedTokens();
|
||||||
|
|
||||||
/* do we need to start a timer to periodically feed tokens to the endpoint? */
|
/* do we need to start a timer to periodically feed tokens to the endpoint? */
|
||||||
if (starting && leftoverTokens > 0) {
|
if (this.isEmpty && leftoverTokens > 0) {
|
||||||
assert(!this.timer);
|
assert(!this.timer);
|
||||||
this.timer = setInterval(async() => {
|
this.timer = setInterval(async() => {
|
||||||
const remaining = await this._feedTokens();
|
const remaining = await this._feedTokens();
|
||||||
|
|||||||
Reference in New Issue
Block a user