#pragma once

#include <string>

namespace r1_voice {

    struct SttConfig {
        std::string whisper_cli;
        std::string whisper_model;

        std::string language = "cs";

        int threads = 8;

        static constexpr int sample_rate = 16000;
        static constexpr int packet_bytes = 5120;

        float speech_threshold = 0.010f;

        int silence_ms = 900;
        int min_speech_ms = 250;
        int max_record_ms = 10000;

        int preroll_ms = 800;
    };

class SpeechToText {
public:
    explicit SpeechToText(SttConfig config);

    // Blocks until the user speaks, stops speaking,
    // and Whisper has transcribed the utterance.
    std::string listen();

private:
    SttConfig config_;

    bool recordToWav(const std::string& path);

    std::string transcribe(
        const std::string& wav_path
    );

    std::string trim(
        const std::string& text
    );
};

} // namespace r1_voice
