feat: prepare Orion transcription pilot
This commit is contained in:
1 parent
ec54ddd0f8
commit
656f144267
4 files changed
+117
-50
No files matched your search
@@ -11,6 +11,7 @@ in
|
||||
...
|
||||
}:
|
||||
let
|
||||
isOrion = config.facts.machine.name == "orion";
|
||||
modelName = "large-v3-turbo-q5_0";
|
||||
modelHash = "sha256-OUIhcJzVrR9AxG5gMcphvOiJMebgiMGIKUxtWlX/p+I=";
|
||||
modelSha256 = builtins.convertHash {
|
||||
@@ -37,6 +38,8 @@ in
|
||||
${builtins.readFile ./_diarize-transcript.py}
|
||||
'';
|
||||
};
|
||||
whisper = if isOrion then pkgs.whisper-cpp else pkgs.whisper-cpp-vulkan;
|
||||
acceleration = if isOrion then "CPU" else "Vulkan";
|
||||
prepareDiarizationModel = pkgs.writeShellApplication {
|
||||
name = "prepare-transcription-diarization-model";
|
||||
runtimeInputs = with pkgs; [
|
||||
@@ -72,18 +75,28 @@ in
|
||||
diarizeTranscript
|
||||
ffmpeg
|
||||
findutils
|
||||
whisper-cpp-vulkan
|
||||
whisper
|
||||
];
|
||||
text = builtins.readFile ./_transcribe-recordings.sh;
|
||||
};
|
||||
home = config.home.homeDirectory;
|
||||
in
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
ffmpeg
|
||||
home.packages = [
|
||||
pkgs.ffmpeg
|
||||
prepareDiarizationModel
|
||||
whisper-cpp-vulkan
|
||||
whisper
|
||||
];
|
||||
|
||||
home.activation.createTranscriptionLayout = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
${pkgs.coreutils}/bin/mkdir -p \
|
||||
"${home}/sync/notes/transcripts" \
|
||||
"${home}/sync/recordings/inbox" \
|
||||
"${home}/sync/recordings/processing" \
|
||||
"${home}/sync/recordings/archive" \
|
||||
"${home}/sync/recordings/failed"
|
||||
'';
|
||||
|
||||
systemd.user.services.transcribe-recordings = {
|
||||
Unit.Description = "Transcribe synchronized recordings with whisper.cpp";
|
||||
|
||||
@@ -91,7 +104,8 @@ in
|
||||
Type = "oneshot";
|
||||
ExecStart = lib.getExe transcribeRecordings;
|
||||
Environment = [
|
||||
"TRANSCRIBE_ENGINE_VERSION=${pkgs.whisper-cpp-vulkan.version}"
|
||||
"TRANSCRIBE_ENGINE_ACCELERATION=${acceleration}"
|
||||
"TRANSCRIBE_ENGINE_VERSION=${whisper.version}"
|
||||
"TRANSCRIBE_MODEL=${model}"
|
||||
''"TRANSCRIBE_MODEL_NAME=${modelName} multilingual"''
|
||||
"TRANSCRIBE_MODEL_SHA256=${modelSha256}"
|
||||
@@ -99,12 +113,30 @@ in
|
||||
"TRANSCRIBE_DIARIZATION_MODEL=${diarizationModel}"
|
||||
"TRANSCRIBE_DIARIZATION_MODEL_NAME=${diarizationModelName}"
|
||||
"TRANSCRIBE_DIARIZATION_MODEL_REVISION=${diarizationModelRevision}"
|
||||
"TRANSCRIBE_SYNC_ROOT=${config.home.homeDirectory}/sync"
|
||||
"TRANSCRIBE_SETTLE_SECONDS=300"
|
||||
"TRANSCRIBE_SYNC_ROOT=${home}/sync"
|
||||
];
|
||||
}
|
||||
// lib.optionalAttrs isOrion {
|
||||
Restart = "on-failure";
|
||||
RestartSec = 60;
|
||||
};
|
||||
|
||||
Install.WantedBy = lib.optionals isOrion [ "default.target" ];
|
||||
};
|
||||
|
||||
systemd.user.timers.transcribe-recordings = {
|
||||
systemd.user.paths.transcribe-recordings = lib.mkIf isOrion {
|
||||
Unit.Description = "Watch for synchronized recordings";
|
||||
|
||||
Path = {
|
||||
PathChanged = "${home}/sync/recordings/inbox";
|
||||
Unit = "transcribe-recordings.service";
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "paths.target" ];
|
||||
};
|
||||
|
||||
systemd.user.timers.transcribe-recordings = lib.mkIf (!isOrion) {
|
||||
Unit.Description = "Transcribe new recordings every two minutes";
|
||||
|
||||
Timer = {
|
||||
|
||||
Reference in new issue
Block a user