mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
* add cmakelist * add paraformer-torch * add debug for funasr-onnx-offline * fix redefinition of jieba StdExtension.hpp * add loading torch models * update funasr-onnx-offline * add SwitchArg for wss-server * add SwitchArg for funasr-onnx-offline * update cmakelist * update funasr-onnx-offline-rtf * add define condition * add gpu define for offlne-stream * update com define * update offline-stream * update cmakelist * update func CompileHotwordEmbedding * add timestamp for paraformer-torch * add C10_USE_GLOG for paraformer-torch * update paraformer-torch * fix func FunASRWfstDecoderInit * update model.h * fix func FunASRWfstDecoderInit * fix tpass_stream * update paraformer-torch * add bladedisc for funasr-onnx-offline * update comdefine * update funasr-wss-server * add log for torch * fix GetValue BLADEDISC * fix log * update cmakelist * update warmup to 10 * update funasrruntime * add batch_size for wss-server * add batch for bins * add batch for offline-stream * add batch for paraformer * add batch for offline-stream * fix func SetBatchSize * add SetBatchSize for model * add SetBatchSize for model * fix func Forward * fix padding * update funasrruntime * add dec reset for batch * set batch default value * add argv for CutSplit * sort frame_queue * sorted msgs * fix FunOfflineInfer * add dynamic batch for fetch * fix FetchDynamic * update run_server.sh * update run_server.sh * cpp http post server support (#1739) * add cpp http server * add some comment * remove some comments * del debug infos * restore run_server.sh * adapt to new model struct * 修复了onnxruntime在macos下编译失败的错误 (#1748) * Add files via upload 增加macos的编译支持 * Add files via upload 增加macos支持 * Add files via upload target_link_directories(funasr PUBLIC ${ONNXRUNTIME_DIR}/lib) target_link_directories(funasr PUBLIC ${FFMPEG_DIR}/lib) 添加 if(APPLE) 限制 --------- Co-authored-by: Yabin Li <wucong.lyb@alibaba-inc.com> * Delete docs/images/wechat.png * Add files via upload * fixed the issues about seaco-onnx timestamp * fix bug (#1764) 当语音识别结果包含 `http` 时,标点符号预测会把它会被当成 url * fix empty asr result (#1765) 解码结果为空的语音片段,text 用空字符串 * docs * docs * docs * docs * docs * keep empty speech result (#1772) * docs * docs * update wechat QRcode * Add python funasr api support for websocket srv (#1777) * add python funasr_api supoort * change little to README.md * add core tools stream * modified a little * fix bug for timeout * support for buffer decode * add ffmpeg decode for buffer * auto frontend * auto frontend --------- Co-authored-by: 雾聪 <wucong.lyb@alibaba-inc.com> Co-authored-by: zhaomingwork <61895407+zhaomingwork@users.noreply.github.com> Co-authored-by: szsteven008 <97944818+szsteven008@users.noreply.github.com> Co-authored-by: Ephemeroptera <605686962@qq.com> Co-authored-by: 彭震东 <zhendong.peng@qq.com> Co-authored-by: Shi Xian <40013335+R1ckShi@users.noreply.github.com> Co-authored-by: 维石 <shixian.shi@alibaba-inc.com>
105 lines
2.2 KiB
C++
105 lines
2.2 KiB
C++
/**
|
|
* Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights
|
|
* Reserved. MIT License (https://opensource.org/licenses/MIT)
|
|
*/
|
|
/* 2023-2024 by zhaomingwork@qq.com */
|
|
//
|
|
// copy some codes from http://www.boost.org/
|
|
//
|
|
|
|
#ifndef HTTP_SERVER2_CONNECTION_HPP
|
|
#define HTTP_SERVER2_CONNECTION_HPP
|
|
|
|
#include <array>
|
|
#include <asio.hpp>
|
|
#include <atomic>
|
|
#include <iostream>
|
|
#include <memory>
|
|
|
|
#include "reply.hpp"
|
|
|
|
#include <fstream>
|
|
|
|
|
|
#include "file_parse.hpp"
|
|
#include "model-decoder.h"
|
|
|
|
|
|
extern std::unordered_map<std::string, int> hws_map_;
|
|
extern int fst_inc_wts_;
|
|
extern float global_beam_, lattice_beam_, am_scale_;
|
|
|
|
namespace http {
|
|
namespace server2 {
|
|
|
|
/// Represents a single connection from a client.
|
|
class connection : public std::enable_shared_from_this<connection> {
|
|
public:
|
|
connection(const connection &) = delete;
|
|
connection &operator=(const connection &) = delete;
|
|
~connection() { std::cout << "one connection is close()" << std::endl; };
|
|
|
|
/// Construct a connection with the given socket.
|
|
explicit connection(asio::ip::tcp::socket socket,
|
|
asio::io_context &io_decoder, int connection_id,
|
|
std::shared_ptr<ModelDecoder> model_decoder);
|
|
|
|
|
|
/// Start the first asynchronous operation for the connection.
|
|
void start();
|
|
std::shared_ptr<FUNASR_MESSAGE> &get_data_msg();
|
|
void write_back(std::string str);
|
|
|
|
private:
|
|
/// Perform an asynchronous read operation.
|
|
void do_read();
|
|
|
|
/// Perform an asynchronous write operation.
|
|
void do_write();
|
|
|
|
void do_decoder();
|
|
|
|
void setup_timer();
|
|
|
|
/// Socket for the connection.
|
|
asio::ip::tcp::socket socket_;
|
|
|
|
|
|
|
|
/// Buffer for incoming data.
|
|
std::array<char, 8192> buffer_;
|
|
/// for time out
|
|
std::shared_ptr<asio::steady_timer> s_timer;
|
|
|
|
|
|
|
|
std::shared_ptr<ModelDecoder> model_decoder;
|
|
|
|
|
|
|
|
int connection_id = 0;
|
|
|
|
/// The reply to be sent back to the client.
|
|
reply reply_;
|
|
|
|
asio::io_context &io_decoder;
|
|
|
|
|
|
|
|
std::shared_ptr<FUNASR_MESSAGE> data_msg;
|
|
|
|
std::mutex m_lock;
|
|
|
|
|
|
std::shared_ptr<asio::io_context::strand> strand_;
|
|
|
|
std::shared_ptr<http::server2::file_parser> file_parse;
|
|
};
|
|
|
|
typedef std::shared_ptr<connection> connection_ptr;
|
|
|
|
} // namespace server2
|
|
} // namespace http
|
|
|
|
#endif // HTTP_SERVER2_CONNECTION_HPP
|