mirror of
https://github.com/baketnk/frame-yap.git
synced 2026-10-06 03:00:04 +02:00
Add bounded dictation state and persistent offline Redux worker
This commit is contained in:
1 parent
f79db54ca9
commit
0cb2991f02
13 files changed
+1132
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace frameyap {
|
||||
|
||||
struct WorkerReply {
|
||||
uint64_t id;
|
||||
std::string text;
|
||||
std::string error;
|
||||
};
|
||||
|
||||
class Worker {
|
||||
public:
|
||||
explicit Worker(std::chrono::milliseconds warmup_timeout = std::chrono::seconds(120),
|
||||
std::chrono::milliseconds request_timeout = std::chrono::seconds(60));
|
||||
~Worker();
|
||||
Worker(const Worker&) = delete;
|
||||
Worker& operator=(const Worker&) = delete;
|
||||
void start(const std::string& python, const std::string& script,
|
||||
const std::string& model, int threads = 2);
|
||||
bool ready() const;
|
||||
void submit(uint64_t id, const std::vector<float>& pcm);
|
||||
std::optional<WorkerReply> poll();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
struct State;
|
||||
std::unique_ptr<State> state_;
|
||||
};
|
||||
|
||||
} // namespace frameyap
|
||||
Reference in new issue
Block a user