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,52 @@
|
||||
#ifndef __TRACK_H__
|
||||
#define __TRACK_H__
|
||||
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include "common.h"
|
||||
#include "ap.h"
|
||||
|
||||
class Track {
|
||||
public:
|
||||
Track(const std::string& trackName, int sampleRate);
|
||||
~Track();
|
||||
|
||||
/* audio production methods */
|
||||
void queueHttpGetAudio(const std::string& url, int gain = 0, bool loop = false);
|
||||
void queueHttpPostAudio(const std::string& url, int gain = 0, bool loop = false);
|
||||
void queueHttpPostAudio(const std::string& url, const std::string& body, std::vector<std::string>& headers, int gain = 0, bool loop = false);
|
||||
void queueFileAudio(const std::string& path, int gain = 0, bool loop = false);
|
||||
void removeAllAudio();
|
||||
|
||||
void onPlayDone(bool hasError, const std::string& errMsg);
|
||||
|
||||
std::string& getTrackName() { return _trackName; }
|
||||
|
||||
/* audio playout methods */
|
||||
bool hasAudio();
|
||||
inline bool hasAudio_NoLock() const {
|
||||
return !_stopping && !_buffer.empty();
|
||||
}
|
||||
|
||||
|
||||
int retrieveAndClearAudio(int16_t* buf, int desiredSamples) {
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
int samplesToCopy = std::min(static_cast<int>(_buffer.size()), desiredSamples);
|
||||
std::copy_n(_buffer.begin(), samplesToCopy, buf);
|
||||
_buffer.erase(_buffer.begin(), _buffer.begin() + samplesToCopy);
|
||||
return samplesToCopy;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _trackName;
|
||||
int _sampleRate;
|
||||
std::mutex _mutex;
|
||||
CircularBuffer_t _buffer;
|
||||
std::queue<std::shared_ptr<AudioProducer>> _apQueue;
|
||||
bool _stopping;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user