remove deepgram tts linear16 wav 44 bytes header (#34)

* remove deepgram tts linear16 wav 44 bytes header

Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com>

* wip

Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com>

---------

Signed-off-by: Hoan HL <quan.luuhoang8@gmail.com>
This commit is contained in:
Hoan Luu Huu
2024-04-05 18:15:02 +07:00
committed by GitHub
parent 8e7f4a3fab
commit d05cfb8ef0

View File

@@ -419,8 +419,14 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
total_bytes_to_process--;
}
size_t numSamples = total_bytes_to_process / sizeof(int16_t);
int16_t* inputData = reinterpret_cast<int16_t*>(data);
if (0 == d->reads++) {
fireEvent = true;
// Deepgram return PCM linear16 WAV file which contains 44 bytes headers, remove that.
inputData += 22;
total_bytes_to_process -= 44;
}
size_t numSamples = total_bytes_to_process / sizeof(int16_t);
{
switch_mutex_lock(d->mutex);
@@ -446,9 +452,6 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
/* Push the data into the buffer */
cBuffer->insert(cBuffer->end(), inputData, inputData + numSamples);
if (0 == d->reads++) {
fireEvent = true;
}
switch_mutex_unlock(d->mutex);
}
if (fireEvent && d->session_id) {