mirror of
https://github.com/jambonz/freeswitch-modules.git
synced 2026-01-25 02:08:27 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b4520c070 | |||
| 9f7a06ce56 | |||
| f7f8f52283 | |||
| 3f06a24b5d |
@@ -557,7 +557,7 @@ namespace {
|
||||
tech_pvt->streamingPreBuffer = nullptr;
|
||||
}
|
||||
|
||||
if (nullptr == tech_pvt->pVecMarksInInventory) {
|
||||
if (tech_pvt->pVecMarksInInventory) {
|
||||
delete static_cast<std::deque<std::string>*>(tech_pvt->pVecMarksInInventory);
|
||||
tech_pvt->pVecMarksInInventory = nullptr;
|
||||
delete static_cast<std::deque<std::string>*>(tech_pvt->pVecMarksInUse);
|
||||
@@ -979,7 +979,7 @@ extern "C" {
|
||||
std::deque<std::string>* pVecInventory = nullptr;
|
||||
std::deque<std::string>* pVecInUse = nullptr;
|
||||
std::deque<std::string>* pVecCleared = nullptr;
|
||||
if (nullptr != tech_pvt->pVecMarksInUse) {
|
||||
if (tech_pvt->pVecMarksInInventory && tech_pvt->pVecMarksInUse && tech_pvt->pVecMarksCleared) {
|
||||
pVecInventory = static_cast<std::deque<std::string>*>(tech_pvt->pVecMarksInInventory);
|
||||
pVecInUse = static_cast<std::deque<std::string>*>(tech_pvt->pVecMarksInUse);
|
||||
pVecCleared = static_cast<std::deque<std::string>*>(tech_pvt->pVecMarksCleared);
|
||||
@@ -1032,7 +1032,7 @@ extern "C" {
|
||||
|
||||
if (samplesToCopy > 0) {
|
||||
vector_add(fp, data, rframe->samples);
|
||||
} else if (pVecInventory != nullptr && pVecInventory->size()) {
|
||||
} else if (pVecInventory && pVecInventory->size()) {
|
||||
// no bidirectional audio to dub but still have some mark in inventory, send them now
|
||||
auto name = pVecInventory->front();
|
||||
pVecInventory->pop_front();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# mod_google_tts
|
||||
|
||||
A Freeswitch module that allows Google Text-to-Speech API to be used as a tts provider.
|
||||
A Freeswitch module that allows Eleven Labs' Text-to-Speech API to be used as a tts provider.
|
||||
|
||||
## API
|
||||
|
||||
### Commands
|
||||
This freeswitch module does not add any new commands, per se. Rather, it integrates into the Freeswitch TTS interface such that it is invoked when an application uses the mod_dptools `speak` command with a tts engine of `google_tts` and a voice equal to the language code associated to one of the [supported Wavenet voices](https://cloud.google.com/text-to-speech/docs/voices)
|
||||
This freeswitch module does not add any new commands, per se. Rather, it integrates into the Freeswitch TTS interface such that it is invoked when an application uses the mod_dptools `speak` command with a tts engine of `elevenlabs` and a voice equal to the language code associated to one of the [supported Eleven Labs voices](https://elevenlabs.io/docs/api-reference/query-library)
|
||||
|
||||
### Events
|
||||
None.
|
||||
@@ -13,11 +13,19 @@ None.
|
||||
## Usage
|
||||
When using [drachtio-fsrmf](https://www.npmjs.com/package/drachtio-fsmrf), you can access this functionality via the speak method on the 'endpoint' object.
|
||||
```js
|
||||
ep.speak({
|
||||
ttsEngine: 'google_tts',
|
||||
voice: 'en-GB-Wavenet-A',
|
||||
text: 'This aggression will not stand'
|
||||
});
|
||||
var text = "Hello World";
|
||||
await endpoint.speak({
|
||||
"ttsEngine": 'elevenlabs',
|
||||
"voice": "W9OIfHh5DtdYiZUcFiql",
|
||||
"text": `{use_speaker_boost=1,optimize_streaming_latency=4,style=0.5,stability=0.5,similarity_boost=0.75,api_key=XXYYZZ,model_id=eleven_turbo_v2}${text}`,
|
||||
});
|
||||
```
|
||||
## Examples
|
||||
[google_tts.js](../../examples/google_tts.js)
|
||||
## Options
|
||||
|
||||
Documentation on these options can be found in Eleven Labs API docs: [Voice Settings](https://elevenlabs.io/docs/speech-synthesis/voice-settings)
|
||||
|
||||
- use_speaker_boost
|
||||
- optimize_streaming_latency
|
||||
- style
|
||||
- stability
|
||||
- similarity_boost
|
||||
|
||||
@@ -233,6 +233,10 @@ static void *SWITCH_THREAD_FUNC grpc_read_thread(switch_thread_t *thread, void *
|
||||
auto speech_event_type = response.speech_event_type();
|
||||
if (response.has_error()) {
|
||||
Status status = response.error();
|
||||
//error 11 is handled in finished session, avoid sending jambonz_transcribe::error event for this here.
|
||||
if (11 == status.code()) {
|
||||
continue;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "grpc_read_thread: error %s (%d)\n", status.message().c_str(), status.code()) ;
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(json, "type", "error");
|
||||
|
||||
@@ -959,8 +959,11 @@ extern "C" {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playht_speech_flush_tts, download complete? %s\n", download_complete ? "yes" : "no") ;
|
||||
ConnInfo_t *conn = (ConnInfo_t *) p->conn;
|
||||
CircularBuffer_t *cBuffer = (CircularBuffer_t *) p->circularBuffer;
|
||||
// In multi threads, only delete the circular buffer when write and read buffer action finished using it.
|
||||
switch_mutex_lock(p->mutex);
|
||||
delete cBuffer;
|
||||
p->circularBuffer = nullptr ;
|
||||
switch_mutex_unlock(p->mutex);
|
||||
|
||||
if (conn) {
|
||||
conn->flushed = true;
|
||||
|
||||
Reference in New Issue
Block a user