mirror of
https://github.com/jambonz/freeswitch-modules.git
synced 2026-01-25 02:08:27 +00:00
Feat/mod dub v2 (#22)
* support tts elevenlabs to mod_dub Signed-off-by: Quan HL <quan.luuhoang8@gmail.com> * wip Signed-off-by: Quan HL <quan.luuhoang8@gmail.com> * wip * wip * fix aws race condition when 2 start transcribes are sent at the same instant * wip * wip * wip * allow queue play on track * wip Signed-off-by: Quan HL <quan.luuhoang8@gmail.com> * revert change for aws transcribe Signed-off-by: Quan HL <quan.luuhoang8@gmail.com> * fix type * wip * wip * rename parameters * rename paramters * wip * wip * wip * wip * wip * bug: there exists scenarios where callback is not defined * wip * wip * revert unintended changes to mod_google_transcribe * fix bugs w/ streaming tts simplified arg parsing to use freeswitch conventions --------- Signed-off-by: Quan HL <quan.luuhoang8@gmail.com> Co-authored-by: Quan HL <quan.luuhoang8@gmail.com>
This commit is contained in:
1 parent
4e57f73c7e
commit
9cdc5fdfca
23 files changed
+1907
-1612
No files matched your search
@@ -0,0 +1,89 @@
|
||||
#ifndef __AP_FILE_H__
|
||||
#define __AP_FILE_H__
|
||||
|
||||
#include <thread>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
|
||||
#include <mpg123.h>
|
||||
|
||||
#include "ap.h"
|
||||
|
||||
class AudioProducerFile : public AudioProducer {
|
||||
public:
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STATUS_NONE = 0,
|
||||
STATUS_FAILED,
|
||||
STATUS_IN_PROGRESS,
|
||||
STATUS_PAUSED,
|
||||
STATUS_COMPLETE,
|
||||
STATUS_AWAITING_RESTART,
|
||||
STATUS_STOPPED
|
||||
} Status_t;
|
||||
|
||||
typedef enum {
|
||||
FILE_TYPE_MP3 = 0,
|
||||
FILE_TYPE_R8
|
||||
} FileType_t;
|
||||
|
||||
const char* status2String(Status_t status)
|
||||
{
|
||||
static const char* statusStrings[] = {
|
||||
"STATUS_NONE",
|
||||
"STATUS_FAILED",
|
||||
"STATUS_IN_PROGRESS",
|
||||
"STATUS_PAUSED",
|
||||
"STATUS_COMPLETE",
|
||||
"STATUS_AWAITING_RESTART",
|
||||
"STATUS_STOPPED"
|
||||
};
|
||||
|
||||
if (status >= 0 && status < sizeof(statusStrings) / sizeof(statusStrings[0]))
|
||||
{
|
||||
return statusStrings[status];
|
||||
}
|
||||
else
|
||||
{
|
||||
return "UNKNOWN_STATUS";
|
||||
}
|
||||
}
|
||||
|
||||
AudioProducerFile(
|
||||
std::mutex& mutex,
|
||||
CircularBuffer_t& circularBuffer,
|
||||
int sampleRate
|
||||
);
|
||||
virtual ~AudioProducerFile();
|
||||
virtual void start(std::function<void(bool, const std::string&)> callback);
|
||||
virtual void stop();
|
||||
void cleanup(Status_t status, std::string errMsg = "");
|
||||
void reset();
|
||||
|
||||
void queueFileAudio(const std::string& path, int gain = 0, bool loop = false);
|
||||
|
||||
void read_cb(const boost::system::error_code& error);
|
||||
|
||||
static bool initialized;
|
||||
static std::thread worker_thread;
|
||||
static boost::asio::io_service io_service;
|
||||
static void threadFunc();
|
||||
|
||||
private:
|
||||
|
||||
static void _init();
|
||||
static void _deinit();
|
||||
|
||||
void stop_file_load();
|
||||
|
||||
std::string _path;
|
||||
Status_t _status;
|
||||
FileType_t _type;
|
||||
mpg123_handle *_mh;
|
||||
boost::asio::deadline_timer _timer;
|
||||
FILE* _fp;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user