Files
freeswitch-modules/mod_dub/ap_file.h
Dave Horton 9cdc5fdfca 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>
2024-03-23 15:37:27 -04:00

89 lines
1.7 KiB
C++

#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