diff --git a/Cargo.lock b/Cargo.lock index a68427d..f5400ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1590,7 +1590,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scribewatch" -version = "0.6.5" +version = "0.6.6" dependencies = [ "anyhow", "async-stream", diff --git a/Cargo.toml b/Cargo.toml index 8ecff4a..e928502 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scribewatch" -version = "0.6.5" +version = "0.6.6" edition = "2024" rust-version = "1.98" authors = ["GodsQuantum"] diff --git a/README.fr.md b/README.fr.md index f37a597..ca386a9 100644 --- a/README.fr.md +++ b/README.fr.md @@ -34,23 +34,25 @@ Le cas d’usage naturel est **notes vocales → Obsidian**, mais rien n’est v Tableau de bord ScribeWatch et Quick Transcribe

-## Télécharger ScribeWatch v0.6.5 +## Télécharger ScribeWatch v0.6.6 -**[Site officiel](https://scribewatch.arezkichougar.com/)** · **[Dernière release GitHub](https://github.com/GodsQuantum/ScribeWatch/releases/latest)** · [Empreintes SHA-256](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.5) · [Code source](https://github.com/GodsQuantum/ScribeWatch) +**[Site officiel](https://scribewatch.arezkichougar.com/)** · **[Dernière release GitHub](https://github.com/GodsQuantum/ScribeWatch/releases/latest)** · [Empreintes SHA-256](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.6) · [Code source](https://github.com/GodsQuantum/ScribeWatch) **Choisissez la version complète pour commencer.** Elle contient les moteurs de transcription et de rédaction locale. Les modèles sont téléchargés au premier lancement ; ensuite, ces traitements locaux ne nécessitent pas d'envoyer les enregistrements ou les textes à un serveur distant. | Système | Version locale complète | Installateur | |---|---|---| -| **Windows 11 x64** | Recommandée | [Installateur Windows complet](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-windows-amd64-standalone-setup.exe) | -| macOS Apple Silicon | IA locale incluse | [DMG Apple Silicon](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-darwin-arm64-standalone.dmg) | -| macOS Intel | IA locale incluse | [DMG Intel](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-darwin-amd64-standalone.dmg) | -| Linux x86-64 | IA locale incluse | [AppImage complète](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-x86_64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/scribewatch_0.6.5_amd64.deb) | -| Linux ARM64 | IA locale incluse | [AppImage complète](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-aarch64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/scribewatch_0.6.5_arm64.deb) | +| **Windows 11 x64** | Recommandée | [Installateur Windows complet](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-windows-amd64-standalone-setup.exe) | +| macOS Apple Silicon | IA locale incluse | [DMG Apple Silicon](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-darwin-arm64-standalone.dmg) | +| macOS Intel | IA locale incluse | [DMG Intel](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-darwin-amd64-standalone.dmg) | +| Linux x86-64 | IA locale incluse | [AppImage complète](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-x86_64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/scribewatch_0.6.6_amd64.deb) | +| Linux ARM64 | IA locale incluse | [AppImage complète](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-aarch64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/scribewatch_0.6.6_arm64.deb) | **Première utilisation :** installez ScribeWatch, laissez les modèles se télécharger une fois (plusieurs gigaoctets), choisissez un type de note, enregistrez ou importez un audio, puis exportez en PDF, Word, ODT, HTML, TXT ou Markdown. Les versions complètes embarquent Pandoc 3.14, Typst 0.15.1 et les polices nécessaires ; inutile de les installer séparément. Un processeur 64 bits récent suffit pour démarrer, mais une carte graphique compatible accélère les traitements ; **16 Go de RAM sont conseillés pour les comptes rendus structurés**, sans constituer un minimum certifié. -**Pour utilisateurs avancés :** des versions légères Windows/macOS/Linux existent dans les [releases GitHub](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.5). Elles **n'installent pas de moteur local de transcription ou de rédaction**. Elles s'adressent à ceux qui disposent déjà de services STT/LLM compatibles. +**Sélection automatique des ports locaux (incluse en v0.6.6) :** sur Windows, macOS et Linux, l’application installée choisit automatiquement un port local libre si son port HTTP habituel est occupé. Les moteurs ASR et LLM intégrés choisissent également des ports libres distincts. Leurs adresses réelles sont réutilisées aux lancements suivants, sans modifier ni arrêter les autres logiciels, ni remplacer les fournisseurs externes configurés. + +**Pour utilisateurs avancés :** des versions légères Windows/macOS/Linux existent dans les [releases GitHub](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.6). Elles **n'installent pas de moteur local de transcription ou de rédaction**. Elles s'adressent à ceux qui disposent déjà de services STT/LLM compatibles. Les installateurs complets et leurs moteurs passent la CI multi-OS, mais les microphones physiques, tous les GPU et la qualité des rapports cliniques ne sont **pas certifiés sur chaque ordinateur**. Les brouillons médicaux doivent être relus par le praticien. Si vous choisissez un fournisseur externe, ses règles de confidentialité s'appliquent. Les binaires peuvent être non signés ou non notarisés : vérifiez les SHA-256. @@ -297,7 +299,7 @@ bash scripts/e2e-v02.sh ## Profil matériel prudent, détecté sans modification -**Versions :** [Tous les installateurs officiels ScribeWatch v0.6.5](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.5), potentiellement non signés ni notarisés. Vérifier les SHA256. +**Versions :** [Tous les installateurs officiels ScribeWatch v0.6.6](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.6), potentiellement non signés ni notarisés. Vérifier les SHA256. ~~~bash python3 scripts/auto-tune.py diff --git a/README.md b/README.md index dcf8cb1..ae8ddb5 100644 --- a/README.md +++ b/README.md @@ -34,23 +34,25 @@ It is especially useful as a **voice notes → Obsidian** bridge, but nothing is ScribeWatch dashboard and Quick Transcribe

-## Download ScribeWatch v0.6.5 +## Download ScribeWatch v0.6.6 -**[Official website](https://scribewatch.arezkichougar.com/)** · **[Latest GitHub release](https://github.com/GodsQuantum/ScribeWatch/releases/latest)** · [SHA-256 checksums](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.5) · [Source code](https://github.com/GodsQuantum/ScribeWatch) +**[Official website](https://scribewatch.arezkichougar.com/)** · **[Latest GitHub release](https://github.com/GodsQuantum/ScribeWatch/releases/latest)** · [SHA-256 checksums](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.6) · [Source code](https://github.com/GodsQuantum/ScribeWatch) **Start with the complete edition.** It includes the local speech-transcription and structured-writing engines. It downloads their model files the first time you open it; after that, processing with those local models does not require sending your recordings or text to a remote service. | Operating system | Complete local edition | Installer | |---|---|---| -| **Windows 11 x64** | Recommended | [Complete Windows installer](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-windows-amd64-standalone-setup.exe) | -| macOS Apple Silicon | Local AI included | [Apple Silicon DMG](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-darwin-arm64-standalone.dmg) | -| macOS Intel | Local AI included | [Intel DMG](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-darwin-amd64-standalone.dmg) | -| Linux x86-64 | Local AI included | [Full AppImage](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-x86_64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/scribewatch_0.6.5_amd64.deb) | -| Linux ARM64 | Local AI included | [Full AppImage](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-aarch64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/scribewatch_0.6.5_arm64.deb) | +| **Windows 11 x64** | Recommended | [Complete Windows installer](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-windows-amd64-standalone-setup.exe) | +| macOS Apple Silicon | Local AI included | [Apple Silicon DMG](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-darwin-arm64-standalone.dmg) | +| macOS Intel | Local AI included | [Intel DMG](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-darwin-amd64-standalone.dmg) | +| Linux x86-64 | Local AI included | [Full AppImage](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-x86_64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/scribewatch_0.6.6_amd64.deb) | +| Linux ARM64 | Local AI included | [Full AppImage](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-aarch64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/scribewatch_0.6.6_arm64.deb) | **Getting started:** Install ScribeWatch, allow the initial model downloads (several gigabytes), choose a note type, record or import audio, then export PDF, DOCX, ODT, HTML, TXT or Markdown. The complete editions bundle Pandoc 3.14, Typst 0.15.1 and multilingual fonts; you do not need system-wide PDF tools. A modern 64-bit processor works, but a compatible GPU speeds up local processing; **16 GB RAM is recommended for structured reports**, not a certified minimum. -**For advanced users only:** Lightweight Windows/macOS/Linux builds are also provided in [GitHub releases](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.5). They **do not install local transcription or writing engines**. Choose them only if you have an existing compatible STT/LLM service. +**Automatic local port recovery (included in v0.6.6):** On Windows, macOS and Linux, the installed application automatically chooses a free local port if the preferred HTTP port is occupied. Its built-in ASR and LLM engines also fall back to separate free ports; the actual addresses are kept for subsequent launches. This never modifies or stops another application, and externally configured endpoints remain unchanged. + +**For advanced users only:** Lightweight Windows/macOS/Linux builds are also provided in [GitHub releases](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.6). They **do not install local transcription or writing engines**. Choose them only if you have an existing compatible STT/LLM service. The complete editions install and start on their certified CI runners, but the physical microphone, every GPU and medical-report accuracy are **not independently certified on all possible computers**. Medical drafts require practitioner review. If you configure an optional external provider, its privacy terms apply; do not assume external providers are local. Binaries may be unsigned or non-notarized; compare SHA-256 checksums before running them. @@ -300,7 +302,7 @@ bash scripts/e2e-v02.sh ## Hardware-aware safe performance starter -**Downloads:** [All official ScribeWatch v0.6.5 installers](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.5). Builds may be unsigned or not Apple-notarized. Check SHA256 before trusting a binary. +**Downloads:** [All official ScribeWatch v0.6.6 installers](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.6). Builds may be unsigned or not Apple-notarized. Check SHA256 before trusting a binary. ~~~bash python3 scripts/auto-tune.py # read-only CPU and RAM detection diff --git a/README.zh-CN.md b/README.zh-CN.md index 0f9ea90..af0ac51 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -6,27 +6,29 @@

ScribeWatch 中文首页

-## ScribeWatch v0.6.5 下载 +## ScribeWatch v0.6.6 下载 -**[官方网站](https://scribewatch.arezkichougar.com/)** · **[最新 GitHub 正式版本](https://github.com/GodsQuantum/ScribeWatch/releases/latest)** · [SHA-256 校验](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.5) · [源代码](https://github.com/GodsQuantum/ScribeWatch) +**[官方网站](https://scribewatch.arezkichougar.com/)** · **[最新 GitHub 正式版本](https://github.com/GodsQuantum/ScribeWatch/releases/latest)** · [SHA-256 校验](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.6) · [源代码](https://github.com/GodsQuantum/ScribeWatch) **新用户请选择完整版本。** 完整安装包包含本地语音转写和文档整理引擎;首次启动需联网下载模型,此后使用本地模型时无需将录音和文档发送至云端。 | 系统 | 完整本地版本 | 安装包 | |---|---|---| -| **Windows 11 x64** | 推荐 | [Windows 完整安装程序](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-windows-amd64-standalone-setup.exe) | -| macOS Apple Silicon | 本地模型 | [Apple Silicon DMG](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-darwin-arm64-standalone.dmg) | -| macOS Intel | 本地模型 | [Intel DMG](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-darwin-amd64-standalone.dmg) | -| Linux x86-64 | 本地模型 | [完整 AppImage](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-x86_64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/scribewatch_0.6.5_amd64.deb) | -| Linux ARM64 | 本地模型 | [完整 AppImage](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/ScribeWatch-0.6.5-aarch64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.5/scribewatch_0.6.5_arm64.deb) | +| **Windows 11 x64** | 推荐 | [Windows 完整安装程序](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-windows-amd64-standalone-setup.exe) | +| macOS Apple Silicon | 本地模型 | [Apple Silicon DMG](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-darwin-arm64-standalone.dmg) | +| macOS Intel | 本地模型 | [Intel DMG](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-darwin-amd64-standalone.dmg) | +| Linux x86-64 | 本地模型 | [完整 AppImage](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-x86_64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/scribewatch_0.6.6_amd64.deb) | +| Linux ARM64 | 本地模型 | [完整 AppImage](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/ScribeWatch-0.6.6-aarch64-standalone.AppImage) · [Debian/Ubuntu .deb](https://github.com/GodsQuantum/ScribeWatch/releases/download/v0.6.6/scribewatch_0.6.6_arm64.deb) | **使用方法:** 安装后首次联网下载数 GB 模型,选择文档类型,录音或导入音频,然后导出 PDF、Word、ODT、HTML、TXT 或 Markdown。完整版本内置 Pandoc 3.14、Typst 0.15.1 及字体,无需另行安装。普通 64 位处理器也可使用,兼容显卡会加快速度;**结构化报告建议 16 GB 内存**,这不是所有设备的保证最低配置。 -**高级用户:** [GitHub 正式版本](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.5) 还提供各平台轻量版。轻量版**不包含本地转写和文档模型**,需要事先配置兼容服务,不适合新用户。 +**自动切换本地端口(已包含在 v0.6.6):** 在 Windows、macOS 和 Linux 上,安装版遇到默认 HTTP 端口被占用时会自动选择空闲的本地端口。内置 ASR 和 LLM 引擎也会分别选择不冲突的端口,并在下次启动时复用实际地址;不会停止其他程序,也不会修改已配置的外部服务。 + +**高级用户:** [GitHub 正式版本](https://github.com/GodsQuantum/ScribeWatch/releases/tag/v0.6.6) 还提供各平台轻量版。轻量版**不包含本地转写和文档模型**,需要事先配置兼容服务,不适合新用户。 安装程序通过多平台 CI 测试,但不同实体麦克风、显卡以及医疗报告质量仍需要单独验证。医疗内容必须由专业人员审阅。选择外部服务时,适用该服务的隐私政策。安装包可能未经过正式代码签名或 Apple 公证,请核对 SHA-256。 -## v0.6.5 当前界面 +## v0.6.6 当前界面 **首页(Home)**:总览、快速转录、监控文件夹入口。**录音(REC)**:浏览器麦克风录制、断线恢复。**文档(Documents)**:历史任务、文档和导出。**设置(Settings)**:转录和 LLM 服务、模型、报告模板、高级参数。支持英语、法语、简体中文、五种主题及简单/高级模式。 diff --git a/docs/RELEASE_NOTES_0.6.6.md b/docs/RELEASE_NOTES_0.6.6.md new file mode 100644 index 0000000..92fb0bd --- /dev/null +++ b/docs/RELEASE_NOTES_0.6.6.md @@ -0,0 +1,17 @@ +# ScribeWatch 0.6.6 — 18 November 2026 + +## Dictation and resilience + +- Native global Rust microphone dictation on Windows, macOS and Linux, using the MIT-licensed Handy recorder core. Audio streams to a temporary WAV file, avoiding a fixed duration limit or retaining the entire recording in RAM. +- Select local or remote ASR provider, model and fallback chain. Configure optional AI structuring with local or remote LLM and document profiles; the raw recognized transcript is preserved if the optional structurer fails. Original browser REC live session, automatic recording recovery, and quick audio-to-text remain available. +- If the HTTP port preferred by the installed desktop app (default 3052, or SCRIBEWATCH_PORT) is occupied, the application automatically selects a free loopback-only port. The bundled STT (38005) and LLM (38080) follow the same policy. Only healthy ScribeWatch sessions are reused; other applications and custom external providers are never stopped or overwritten. +- The app stores the actual healthy main port for later launches and dynamically updates ScribeWatch-owned native provider URLs if those ports change. +- Compatible Windows x64, macOS ARM64/Intel, Linux x86-64/ARM64 and Docker/server binaries are built from a single tagged source tree. + +## Verification and boundaries + +- Branch PR #52: Linux native Rust unit suite (194 passed, one ignored), first-boot integration (3), real launcher/engine port-collision integration (1), launcher unit (4), and frontend tests (120) passed locally, with strict Clippy and zero Svelte diagnostics. +- Release GitHub Actions must pass all platform and installer jobs, verify final checksums and only then publish the version as non-draft. Hardware microphone/keyboard, individual GPU models, Apple notarization and Windows Authenticode signing are not universally certified. +- The full local edition obtains ASR and LLM model weights on first launch; no hidden cloud inference is enabled. Lightweight builds may require external providers. Existing configurations are retained. + +See README.md, README.fr.md and README.zh-CN.md for downloads and limitations. diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 5d51e12..5822422 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "scribewatch-frontend", - "version": "0.6.5", + "version": "0.6.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "scribewatch-frontend", - "version": "0.6.5", + "version": "0.6.6", "dependencies": { "pdf-lib": "1.17.1" }, diff --git a/frontend/package.json b/frontend/package.json index 90d9aec..98c88ca 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "scribewatch-frontend", "private": true, - "version": "0.6.5", + "version": "0.6.6", "type": "module", "scripts": { "dev": "vite dev", diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 4a9c53d..e26814f 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -1,8 +1,8 @@ import { parseApiResponse } from './api-response.js'; import type { - EmbeddedRuntimeStatus, Space, SpaceMembership, SpaceKind, + DictationResult, DictationSettings, EmbeddedRuntimeStatus, Space, SpaceMembership, SpaceKind, BrowseResponse, DashboardStats, ExportFormat, Job, LiveUploadManifest, LlmProvider, LlmProviderInput, - Provider, ProviderInput, QuickOptions, ReportEncounter, SavedReport, StructureProfile, Workflow + Provider, ProviderInput, TranscriptionRoute, QuickOptions, ReportEncounter, SavedReport, StructureProfile, Workflow } from './types'; export class ApiError extends Error { @@ -163,6 +163,21 @@ export const api = { retryJob: (id: string) => request(`/api/v1/jobs/${id}/retry`, { method: 'POST' }), cancelJob: (id: string) => request(`/api/v1/jobs/${id}/cancel`, { method: 'POST' }), deleteJob: (id: string) => request(`/api/v1/jobs/${id}`, { method: 'DELETE' }), + dictationSettings: () => request('/api/v1/dictation/settings'), + saveDictationSettings: (settings:DictationSettings) => + request('/api/v1/dictation/settings', { + method:'PUT',body:JSON.stringify(settings) + }), + dictationTranscribe: async ( + file:File, + options:{transcriptionChain:TranscriptionRoute[];language?:string}, + ):Promise => { + const form=new FormData(); + form.append('file',file); + form.append('transcriptionChain',JSON.stringify(options.transcriptionChain)); + form.append('language',options.language??''); + return request('/api/v1/dictation/transcribe',{method:'POST',body:form}); + }, quickServer: (sourcePath: string, options: QuickOptions) => request('/api/v1/quick/server', { method: 'POST', body: JSON.stringify({ sourcePath, ...options }) }), diff --git a/frontend/src/lib/dictation.ts b/frontend/src/lib/dictation.ts new file mode 100644 index 0000000..fb6ee33 --- /dev/null +++ b/frontend/src/lib/dictation.ts @@ -0,0 +1,12 @@ +/** Prefer native browser encoders over an extra transcription runtime. */ +export const recorderFormats = ['audio/webm;codecs=opus','audio/mp4','audio/ogg;codecs=opus'] as const; +export function chooseRecorderMime(supports:(mime:string)=>boolean):string { + return recorderFormats.find(supports)??''; +} +export function recordedFile(chunks:Blob[], mime:string, date=new Date()):File { + const blob=new Blob(chunks,{type:mime||chunks[0]?.type||'audio/webm'}); + if(!blob.size)throw new Error('Aucun son enregistré.'); + const ext=blob.type.includes('mp4')?'m4a':blob.type.includes('ogg')?'ogg':'webm'; + const name='dictation-'+date.toISOString().replace(/[:.]/g,'-')+'.'+ext; + return new File([blob],name,{type:blob.type}); +} diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index 96a4160..c1f8065 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -176,6 +176,19 @@ export interface Job { updatedAtMs: number; } +export interface DictationSettings { + transcriptionChain: TranscriptionRoute[]; + language: string; + structureProfileId?: string | null; +} + +export interface DictationResult { + text: string; + providerId: string; + model: string; + elapsedMs: number; +} + export interface QuickOptions { providerId?: string; model?: string; diff --git a/frontend/src/lib/ui-mode.ts b/frontend/src/lib/ui-mode.ts index 7383923..a07c256 100644 --- a/frontend/src/lib/ui-mode.ts +++ b/frontend/src/lib/ui-mode.ts @@ -1,9 +1,10 @@ /** A reduced navigation surface; advanced features are never disabled. */ export type UiMode='simple'|'advanced'; -export type View='home'|'quick'|'live'|'workflows'|'jobs'|'settings'; +export type View='home'|'quick'|'live'|'dictation'|'workflows'|'jobs'|'settings'; const simpleItems=[ {id:'home',label:'Home',glyph:'⌂'}, {id:'live',label:'REC',glyph:'●'}, + {id:'dictation',label:'Dictée',glyph:'⌨'}, {id:'jobs',label:'Documents',glyph:'≡'}, {id:'settings',label:'Settings',glyph:'⚙'} ] as const; @@ -11,6 +12,7 @@ const advancedItems=[ {id:'home',label:'Home',glyph:'⌂'}, {id:'quick',label:'Quick',glyph:'✦'}, {id:'live',label:'REC',glyph:'●'}, + {id:'dictation',label:'Dictée',glyph:'⌨'}, {id:'workflows',label:'Workflows',glyph:'↻'}, {id:'jobs',label:'Documents',glyph:'≡'}, {id:'settings',label:'Settings',glyph:'⚙'} diff --git a/frontend/src/lib/views/AiProfilesView.svelte b/frontend/src/lib/views/AiProfilesView.svelte index c68b12f..8d44a2e 100644 --- a/frontend/src/lib/views/AiProfilesView.svelte +++ b/frontend/src/lib/views/AiProfilesView.svelte @@ -95,6 +95,8 @@ } let embedded:EmbeddedRuntimeStatus={desktop:false,engines:[],download:{status:'',model:''}}; + $: embeddedSttOrigin = embedded.engines.find((engine)=>engine.kind==='stt')?.endpoint + ?.replace(/\/v1\/audio\/transcriptions$/, '') ?? 'http://127.0.0.1:38005'; let embeddedBusy=false; let selectedSTT='handy-computer/parakeet-ultra-gguf'; let selectedLLM='unsloth/Qwen3.5-4B-GGUF:Q4_K_M'; @@ -187,7 +189,7 @@ const model=embeddedLlmModels[0]??''; newProvider(); providerDraft={...providerDraft,name:'LLM intégré ScribeWatch', - chatCompletionsUrl:'http://127.0.0.1:38080/v1/chat/completions',model}; + chatCompletionsUrl:embedded.engines.find((e)=>e.kind==='llm')?.endpoint??'http://127.0.0.1:38080/v1/chat/completions',model}; providerModels=[...embeddedLlmModels]; } async function connectEmbeddedStt(){ @@ -196,7 +198,7 @@ embeddedBusy=true; try{ await api.saveProvider({id:'',name:'Transcription intégrée ScribeWatch', - transcriptionUrl:'http://127.0.0.1:38005/v1/audio/transcriptions', + transcriptionUrl:embedded.engines.find((e)=>e.kind==='stt')?.endpoint??'http://127.0.0.1:38005/v1/audio/transcriptions', model,timeoutSeconds:600,enabled:true,apiKey:''}); await refresh(); notify('success','Fournisseur de transcription interne créé. Choisissez-le pour vos workflows.'); @@ -328,7 +330,7 @@
- Gestion avancée des modèles ASR + Gestion avancée des modèles ASR
+ 2. Microphone +

Navigateur : Ctrl+Maj+D. Application installée : Ctrl+Alt+D partout (raccourci global) ou menu ScribeWatch dans la zone de notification. La transcription sera insérée dans l’application active si les permissions système le permettent.

+ {#if recording} + + Enregistrement en cours… + {:else} + + {/if} +
+ + + + diff --git a/frontend/src/lib/views/LiveRecordView.svelte b/frontend/src/lib/views/LiveRecordView.svelte index 2cd46f9..3ffa499 100644 --- a/frontend/src/lib/views/LiveRecordView.svelte +++ b/frontend/src/lib/views/LiveRecordView.svelte @@ -378,7 +378,7 @@ const exportFormats:ExportFormat[]=['md','txt','html','docx','odt','pdf']; $: if(!chainInitialized&&providers.length){ - const provider=providers.find((candidate)=>candidate.enabled && /parakeet.ultra/i.test(candidate.model) && /127\.0\.0\.1:38005|localhost:38005/i.test(candidate.transcriptionUrl))??providers.find((candidate)=>candidate.enabled && /parakeet.ultra/i.test(candidate.model))??providers.find((candidate)=>candidate.enabled)??providers[0]; + const provider=providers.find((candidate)=>candidate.enabled && candidate.id==='scribewatch-native-parakeet' && /parakeet.ultra/i.test(candidate.model))??providers.find((candidate)=>candidate.enabled && /parakeet.ultra/i.test(candidate.model))??providers.find((candidate)=>candidate.enabled)??providers[0]; transcriptionChain=[{providerId:provider.id,model:provider.model}]; chainInitialized=true; } diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index d100871..332e4fd 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -9,6 +9,7 @@ import DashboardView from '$lib/views/DashboardView.svelte'; import QuickTranscribeView from '$lib/views/QuickTranscribeView.svelte'; import LiveRecordView from '$lib/views/LiveRecordView.svelte'; + import DictationView from '$lib/views/DictationView.svelte'; import WorkflowsView from '$lib/views/WorkflowsView.svelte'; import SettingsView from '$lib/views/SettingsView.svelte'; import JobsView from '$lib/views/JobsView.svelte'; @@ -124,6 +125,7 @@ {:else if active==='home'} {:else if active==='quick'} {:else if active==='live'} + {:else if active==='dictation'} {:else if active==='workflows'} {:else if active==='settings'} {:else}{ + assert.equal(chooseRecorderMime(m=>m==='audio/mp4'),'audio/mp4'); + assert.equal(chooseRecorderMime(()=>false),''); + assert.equal(chooseRecorderMime(()=>true),'audio/webm;codecs=opus'); +}); +test('browser dictation builds a valid audio file without an arbitrary byte cap',()=>{ + const file=recordedFile([new Blob(['sound'],{type:'audio/webm'})], 'audio/webm', new Date('2026-11-18T08:00:00Z')); + assert.equal(file.type,'audio/webm'); + assert.equal(file.size,5); + assert.match(file.name,/dictation-2026-11-18T08-00-00-000Z.webm/); + assert.throws(()=>recordedFile([], ''),/Aucun son/); + +}); +test('dictation UI reuses providers and optional structure instead of a second engine',async()=>{ + const fs=await import('node:fs/promises'); + const body=await fs.readFile(new URL('../src/lib/views/DictationView.svelte',import.meta.url),'utf8'); + assert.match(body,/TranscriptionChainEditor/); + assert.match(body,/api\.dictationTranscribe\(/); + assert.match(body,/api\.structureExisting\(/); + assert.match(body,/releaseMicrophone/); + assert.match(body,/navigator\.clipboard\.writeText/); +}); diff --git a/frontend/tests/ui-mode.test.mjs b/frontend/tests/ui-mode.test.mjs index 0b29eff..ced7b69 100644 --- a/frontend/tests/ui-mode.test.mjs +++ b/frontend/tests/ui-mode.test.mjs @@ -2,16 +2,17 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import { navigationItems, navigationAllows, normalizeMode, normalizeView } from '../src/lib/ui-mode.ts'; -test('new installs expose only the four essential destinations', () => { +test('new installs expose recording, dictation and essential destinations', () => { assert.equal(normalizeMode(null), 'simple'); - assert.deepEqual(navigationItems('simple').map(item => item.id), ['home', 'live', 'jobs', 'settings']); + assert.deepEqual(navigationItems('simple').map(item => item.id), ['home', 'live', 'dictation', 'jobs', 'settings']); assert.equal(navigationAllows('simple', 'providers'), false); assert.equal(navigationAllows('simple', 'settings'), true); + assert.equal(navigationAllows('simple', 'dictation'), true); }); test('advanced mode preserves existing workflows without showing two configuration sections in the rail', () => { assert.deepEqual(navigationItems('advanced').map(item => item.id), - ['home', 'quick', 'live', 'workflows', 'jobs', 'settings']); + ['home', 'quick', 'live', 'dictation', 'workflows', 'jobs', 'settings']); assert.equal(navigationAllows('advanced', 'workflows'), true); assert.equal(navigationAllows('advanced', 'ai'), false); assert.equal(normalizeMode('advanced'), 'advanced'); diff --git a/packaging/desktop/README.md b/packaging/desktop/README.md index e9b96c6..b1d73ca 100644 --- a/packaging/desktop/README.md +++ b/packaging/desktop/README.md @@ -46,8 +46,18 @@ Smoke CI, Docker, network-only deployments and existing configured profiles are excluded to preserve user settings and external engines. Advanced Settings still permit Internal, External and Disabled separately. -Native STT binds only to 127.0.0.1:38005 and LLM to 127.0.0.1:38080. -Switching to External/Disabled stops the owned child without deleting files. +Installed Windows, macOS and Linux launcher uses a loopback-only HTTP server, +preferring 127.0.0.1:3052. When that port is occupied by another application, +it selects a free ephemeral port through the OS, opens the correct URL, and +stores the chosen port in user-local server.port for subsequent launches. +The native STT and LLM engines similarly prefer 38005 and 38080 respectively, +falling back to separate OS-selected free ports without interfering with +existing services. Their actual URLs are returned through embedded/status +and reflected in ScribeWatch-owned provider configuration at launch, including +after a port change. Docker/server CLI explicitly configured ports remain +unchanged; external endpoints and other applications are never stopped. +Switching to External/Disabled stops only ScribeWatch-owned child engines, +without deleting files. The STT model UI reuses Speaches-compatible native model APIs and single HF cache: Whisper, Parakeet Ultra, Qwen3-ASR, Nemotron and custom GGUF quantizations. diff --git a/packaging/desktop/launcher/Cargo.lock b/packaging/desktop/launcher/Cargo.lock index 70db347..adff354 100644 --- a/packaging/desktop/launcher/Cargo.lock +++ b/packaging/desktop/launcher/Cargo.lock @@ -21,6 +21,28 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "alsa" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d" +dependencies = [ + "alsa-sys", + "bitflags 2.13.2", + "cfg-if", + "libc", +] + +[[package]] +name = "alsa-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad7569085a265dd3f607ebecce7458eaab2132a84393534c95b18dcbc3f31e04" +dependencies = [ + "libc", + "pkg-config", +] + [[package]] name = "android-activity" version = "0.6.1" @@ -46,6 +68,24 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" +[[package]] +name = "arboard" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917" +dependencies = [ + "clipboard-win", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "windows-sys 0.61.2", + "wl-clipboard-rs", + "x11rb", +] + [[package]] name = "arc-swap" version = "1.9.3" @@ -61,6 +101,37 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" +[[package]] +name = "ashpd" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33a3c86f3fd70c0ffa500ed189abfa90b5a52398a45d5dc372fcc38ebeb7a645" +dependencies = [ + "enumflags2", + "futures-channel", + "futures-util", + "rand 0.9.5", + "serde", + "serde_repr", + "tokio", + "url", + "zbus", +] + +[[package]] +name = "ashpd" +version = "0.13.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb8421aaa9644a5faf26735f258b669b15f063313ef8f8e2bdb28912a1a6f111" +dependencies = [ + "enumflags2", + "futures-util", + "getrandom 0.4.3", + "serde", + "tokio", + "zbus", +] + [[package]] name = "async-broadcast" version = "0.7.2" @@ -198,12 +269,80 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "audio-codec-algorithms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1254ebf6529f3763c491acfb5ab6e960809e3c75a38584cc664f8c5667fb7107" + +[[package]] +name = "audioadapter" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1292ef9edf681b7426ed089004b021a42896492f58bd0c909ad44e5faec9ac4" + +[[package]] +name = "audioadapter-buffers" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46289a81a3bfa26d0f8b2415f8ca9decde9a66308a150568af5c102381b3c8ce" +dependencies = [ + "audioadapter", + "audioadapter-sample", + "num-traits", +] + +[[package]] +name = "audioadapter-sample" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5258faecf4edbe35ec483bda9b1f7438e6b391891819269c6b5461aeaa0e8d7d" +dependencies = [ + "audio-codec-algorithms", + "num-traits", +] + [[package]] name = "autocfg" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" +[[package]] +name = "aws-lc-rs" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048006790404103c488e6c5616b3e7e702a71292aadda08e8f7698a9e0d2eb53" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bfbe32ac36b3c428696ce315464181bc4029d689fd58e3f2a4e58c252242f52" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + [[package]] name = "bitflags" version = "1.3.2" @@ -215,6 +354,9 @@ name = "bitflags" version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] [[package]] name = "block2" @@ -259,6 +401,12 @@ version = "1.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "byteorder-lite" version = "0.1.0" @@ -321,6 +469,35 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core 0.10.1", +] + +[[package]] +name = "clipboard-win" +version = "5.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" +dependencies = [ + "error-code", +] + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + [[package]] name = "combine" version = "4.6.9" @@ -350,6 +527,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -363,8 +550,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.10.1", + "core-graphics-types 0.2.0", "foreign-types", "libc", ] @@ -376,7 +576,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.10.1", + "libc", +] + +[[package]] +name = "coreaudio-rs" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5d7dca3ebcf65a035582c9ad4385371a9d9ee6537474d2a278f4e1e475bb58" +dependencies = [ + "bitflags 2.13.2", + "libc", + "objc2-audio-toolbox", + "objc2-core-audio", + "objc2-core-audio-types", + "objc2-core-foundation", +] + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ "libc", ] @@ -419,6 +653,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + [[package]] name = "dispatch" version = "0.2.0" @@ -435,6 +675,17 @@ dependencies = [ "objc2 0.6.5", ] +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "dlib" version = "0.5.3" @@ -456,12 +707,54 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "endi" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" +[[package]] +name = "enigo" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71c6c56e50f7acae2906a0dcbb34529ca647e40421119ad5d12e7f8ba6e50010" +dependencies = [ + "ashpd 0.12.3", + "core-foundation 0.10.1", + "core-graphics 0.25.0", + "foreign-types-shared", + "futures", + "libc", + "log", + "nom", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "reis", + "tokio", + "windows 0.61.3", + "x11rb", + "xkbcommon", + "xkeysym", +] + +[[package]] +name = "enum-primitive-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7795da175654fe16979af73f81f26a8ea27638d8d9823d317016888a63dc4c" +dependencies = [ + "num-traits", + "quote", + "syn 2.0.119", +] + [[package]] name = "enumflags2" version = "0.7.12" @@ -499,6 +792,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "error-code" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" + [[package]] name = "event-listener" version = "5.4.2" @@ -540,6 +839,12 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" +[[package]] +name = "fixedbitset" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175" + [[package]] name = "flate2" version = "1.1.10" @@ -551,6 +856,12 @@ dependencies = [ "zlib-rs", ] +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foreign-types" version = "0.5.0" @@ -578,6 +889,36 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.34" @@ -585,6 +926,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -593,6 +935,17 @@ version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.34" @@ -623,6 +976,12 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + [[package]] name = "futures-task" version = "0.3.34" @@ -635,9 +994,13 @@ version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ + "futures-channel", "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "slab", ] @@ -649,7 +1012,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ "rustix 1.1.6", - "windows-link", + "windows-link 0.2.1", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", ] [[package]] @@ -671,19 +1047,84 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi 6.0.0", + "rand_core 0.10.1", + "wasm-bindgen", ] [[package]] -name = "hashbrown" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" - -[[package]] -name = "hermit-abi" -version = "0.5.3" +name = "handy-cpal" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b0f0a55e498d0260eae6bc9a61a976b60d0c014c038771d6fbcc95907b79d4" +dependencies = [ + "alsa", + "block2 0.6.2", + "coreaudio-rs", + "dasp_sample", + "futures", + "jni", + "js-sys", + "libc", + "mach2", + "ndk", + "ndk-context", + "num-derive", + "num-traits", + "objc2 0.6.5", + "objc2-audio-toolbox", + "objc2-avf-audio", + "objc2-core-audio", + "objc2-core-audio-types", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "portable-atomic", + "pulseaudio", + "web-sys", + "windows 0.62.2", + "windows-core 0.62.2", +] + +[[package]] +name = "handy-recorder" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29602f3465cb080cc437b08903ea7ef395c55a41120264a897acdd25ff9b255a" +dependencies = [ + "dasp_sample", + "futures", + "handy-cpal", + "libc", + "log", + "objc2-av-foundation", + "objc2-core-audio", + "objc2-core-foundation", + "pulseaudio", + "rtrb", + "rubato", + "windows 0.62.2", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "hermit-abi" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" @@ -693,6 +1134,213 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hound" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" +dependencies = [ + "atomic-waker", + "bytes", + "futures-core", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "image" version = "0.25.9" @@ -713,9 +1361,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.17.1", ] +[[package]] +name = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + [[package]] name = "jni" version = "0.22.4" @@ -730,7 +1390,7 @@ dependencies = [ "simd_cesu8", "thiserror 2.0.21", "walkdir", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -795,6 +1455,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "keyboard-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" +dependencies = [ + "bitflags 2.13.2", + "serde", + "unicode-segmentation", +] + [[package]] name = "keyboard-types" version = "0.8.3" @@ -838,7 +1509,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" dependencies = [ "cfg-if", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -865,12 +1536,39 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" +[[package]] +name = "lru-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" + +[[package]] +name = "mach2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dae608c151f68243f2b000364e1f7b186d9c29845f7d2d85bd31b9ad77ad552b" + [[package]] name = "memchr" version = "2.8.3" @@ -895,6 +1593,22 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -915,6 +1629,18 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mio" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.61.2", +] + [[package]] name = "moxcms" version = "0.7.11" @@ -933,7 +1659,7 @@ checksum = "4340e89c178916e62879c5c36b7f699019369be413e496178a6983ce91b8bc03" dependencies = [ "crossbeam-channel", "dpi", - "keyboard-types", + "keyboard-types 0.8.3", "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-core-foundation", @@ -972,6 +1698,44 @@ dependencies = [ "jni-sys 0.3.1", ] +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1053,6 +1817,44 @@ dependencies = [ "bitflags 2.13.2", "objc2 0.6.5", "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-audio-toolbox" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6948501a91121d6399b79abaa33a8aa4ea7857fe019f341b8c23ad6e81b79b08" +dependencies = [ + "bitflags 2.13.2", + "libc", + "objc2 0.6.5", + "objc2-core-audio", + "objc2-core-audio-types", + "objc2-core-foundation", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-av-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478ae33fcac9df0a18db8302387c666b8ef08a3e2d62b510ca4fc278a384b6c0" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-avf-audio" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-foundation 0.3.2", ] @@ -1080,6 +1882,29 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-core-audio" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1eebcea8b0dbff5f7c8504f3107c68fc061a3eb44932051c8cf8a68d969c3b2" +dependencies = [ + "dispatch2", + "objc2 0.6.5", + "objc2-core-audio-types", + "objc2-core-foundation", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-core-audio-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a89f2ec274a0cf4a32642b2991e8b351a404d290da87bb6a9a9d8632490bd1c" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", +] + [[package]] name = "objc2-core-data" version = "0.2.2" @@ -1099,7 +1924,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "dispatch2", + "libc", "objc2 0.6.5", ] @@ -1110,7 +1937,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", "objc2-core-foundation", + "objc2-io-surface", ] [[package]] @@ -1164,6 +1994,18 @@ checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ "bitflags 2.13.2", "block2 0.6.2", + "libc", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.13.2", "objc2 0.6.5", "objc2-core-foundation", ] @@ -1266,6 +2108,12 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "openssl-probe" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1" + [[package]] name = "orbclient" version = "0.3.55" @@ -1286,12 +2134,45 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "os_pipe" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "parking" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link 0.2.1", +] + [[package]] name = "pastey" version = "0.2.3" @@ -1304,6 +2185,17 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + [[package]] name = "pin-project" version = "1.1.13" @@ -1380,6 +2272,39 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "primal-check" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" +dependencies = [ + "num-integer", +] + [[package]] name = "proc-macro-crate" version = "3.5.0" @@ -1398,59 +2323,296 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "pulseaudio" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba79a4c6904c987cc31fa50e9b750539404511c2dbd9ce95e5e58444177a21e" +dependencies = [ + "bitflags 2.13.2", + "byteorder", + "enum-primitive-derive", + "futures", + "log", + "mio", + "num-traits", + "thiserror 1.0.69", +] + [[package]] name = "pxfm" version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quinn" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.21", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.4.3", + "lru-slab", + "rand 0.10.4", + "rand_pcg", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.21", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.61.2", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a" +dependencies = [ + "rand_core 0.10.1", +] + +[[package]] +name = "realfft" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "538895ccf2006b473aafbe8d72770e21038961ab67aae34f3c577485fc703a7d" +dependencies = [ + "rustfft", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] [[package]] -name = "quick-xml" -version = "0.41.0" +name = "reis" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +checksum = "00939c5c526a1b4054ef8d9d96b3f92227f08ca355965e986741b556eda6d289" dependencies = [ - "memchr", + "rustix 0.38.44", ] [[package]] -name = "quote" -version = "1.0.47" +name = "reqwest" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +checksum = "219c5811de6525e5416c7d5d53bb656d3afdbc6c5af816e0802bcfa42dbdc1c3" dependencies = [ - "proc-macro2", + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", + "serde", + "serde_json", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", ] [[package]] -name = "r-efi" -version = "5.3.0" +name = "ring" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] [[package]] -name = "r-efi" -version = "6.0.0" +name = "rtrb" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" +checksum = "5974e397833d890f2f74963408e0d4a6cd8eda2f6a445ae06750291b5d7a997e" [[package]] -name = "redox_syscall" -version = "0.4.1" +name = "rubato" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "a7cb1ffaf8738df50aab642a7f6465df81c6ba9e2818268053487165298114be" dependencies = [ - "bitflags 1.3.2", + "audioadapter", + "audioadapter-buffers", + "num-complex", + "num-integer", + "num-traits", + "realfft", + "visibility", + "windowfunctions", ] [[package]] -name = "redox_syscall" -version = "0.9.5" +name = "rustc-hash" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" -dependencies = [ - "bitflags 2.13.2", -] +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" [[package]] name = "rustc_version" @@ -1461,6 +2623,20 @@ dependencies = [ "semver", ] +[[package]] +name = "rustfft" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21db5f9893e91f41798c88680037dba611ca6674703c1a18601b01a72c8adb89" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "primal-check", + "strength_reduce", + "transpose", +] + [[package]] name = "rustix" version = "0.38.44" @@ -1487,6 +2663,81 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "aws-lc-rs", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a073f5dc7469f984c52ad2752b63b0807745133b6de880b7b64c1ac4c48aec4" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" + +[[package]] +name = "rustls-webpki" +version = "0.103.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.23" @@ -1502,23 +2753,70 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cb23c424d8ee841bb4d813677ca237e2a610067d594fec130f87d6093495ab5" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "scoped-tls" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "scribewatch-desktop-launcher" -version = "0.6.5" +version = "0.6.6" dependencies = [ + "arboard", + "enigo", + "handy-recorder", + "hound", "image", + "reqwest", + "serde", + "serde_json", "tray-icon", + "uuid", + "wayclip-global-hotkey", "winit", "winreg", "winresource", ] +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.10.1", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.28" @@ -1555,6 +2853,19 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + [[package]] name = "serde_repr" version = "0.1.21" @@ -1659,6 +2970,34 @@ dependencies = [ "serde", ] +[[package]] +name = "socket2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.119" @@ -1681,6 +3020,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "task-local" version = "0.1.1" @@ -1743,13 +3102,46 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + [[package]] name = "tokio" version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" dependencies = [ + "bytes", + "libc", + "mio", "pin-project-lite", + "signal-hook-registry", + "socket2", + "tracing", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" +dependencies = [ + "rustls", + "tokio", ] [[package]] @@ -1803,6 +3195,51 @@ version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "bitflags 2.13.2", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.44" @@ -1834,6 +3271,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + [[package]] name = "tray-icon" version = "0.26.1" @@ -1855,27 +3302,84 @@ dependencies = [ ] [[package]] -name = "uds_windows" -version = "1.2.1" +name = "tree_magic_mini" +version = "3.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" +dependencies = [ + "memchr", + "nom", + "petgraph", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "uds_windows" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset", + "tempfile", + "windows-sys 0.61.2", +] + +[[package]] +name = "unicase" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" dependencies = [ - "memoffset", - "tempfile", - "windows-sys 0.61.2", + "form_urlencoded", + "idna", + "percent-encoding", + "serde", + "serde_derive", ] [[package]] -name = "unicode-ident" -version = "1.0.27" +name = "utf8_iter" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] [[package]] -name = "unicode-segmentation" -version = "1.13.3" +name = "utf_types" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" [[package]] name = "uuid" @@ -1883,6 +3387,7 @@ version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" dependencies = [ + "getrandom 0.4.3", "js-sys", "serde_core", "wasm-bindgen", @@ -1894,6 +3399,17 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "visibility" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d674d135b4a8c1d7e813e2f8d1c9a58308aee4a680323066025e53132218bd91" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "walkdir" version = "2.5.0" @@ -1904,6 +3420,21 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + [[package]] name = "wasip2" version = "1.0.4+wasi-0.2.12" @@ -1968,6 +3499,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wayclip-global-hotkey" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e27d52b16a43170fe15eb89d2a88a4921d7d50cc740b64b5d091bc9bf8532dd" +dependencies = [ + "ashpd 0.13.13", + "crossbeam-channel", + "futures", + "keyboard-types 0.7.0", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "once_cell", + "thiserror 2.0.21", + "tokio", + "windows-sys 0.59.0", + "x11rb", + "xkeysym", +] + [[package]] name = "wayland-backend" version = "0.3.17" @@ -2096,6 +3647,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "293198dcebfb821155b5092ab94b5a82ff180eddd7241df3bd6e66a4ffd1a585" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi-util" version = "0.1.11" @@ -2105,12 +3665,196 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "windowfunctions" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90628d739333b7c5d2ee0b70210b97b8cddc38440c682c96fd9e2c24c2db5f3a" +dependencies = [ + "num-traits", +] + +[[package]] +name = "windows" +version = "0.61.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections 0.2.0", + "windows-core 0.61.2", + "windows-future 0.2.1", + "windows-link 0.1.3", + "windows-numerics 0.2.0", +] + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections 0.3.2", + "windows-core 0.62.2", + "windows-future 0.3.2", + "windows-numerics 0.3.1", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +dependencies = [ + "windows-core 0.61.2", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core 0.62.2", +] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + +[[package]] +name = "windows-future" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", + "windows-threading 0.1.0", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core 0.62.2", + "windows-link 0.2.1", + "windows-threading 0.2.1", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-numerics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core 0.62.2", + "windows-link 0.2.1", +] + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link 0.2.1", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows-sys" version = "0.52.0" @@ -2135,7 +3879,7 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -2154,6 +3898,24 @@ dependencies = [ "windows_x86_64_msvc", ] +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -2217,8 +3979,8 @@ dependencies = [ "calloop", "cfg_aliases", "concurrent-queue", - "core-foundation", - "core-graphics", + "core-foundation 0.9.4", + "core-graphics 0.23.2", "cursor-icon", "dpi", "js-sys", @@ -2287,6 +4049,30 @@ version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" +[[package]] +name = "wl-clipboard-rs" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "959c7ac3b8afde864f7a7448ac16f29b2b83350b7eccbf77fb781c3999aa6848" +dependencies = [ + "libc", + "log", + "os_pipe", + "rustix 1.1.6", + "thiserror 2.0.21", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + [[package]] name = "x11-dl" version = "2.21.0" @@ -2325,6 +4111,17 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" +[[package]] +name = "xkbcommon" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a974f48060a14e95705c01f24ad9c3345022f4d97441b8a36beb7ed5c4a02d" +dependencies = [ + "libc", + "memmap2", + "xkeysym", +] + [[package]] name = "xkbcommon-dl" version = "0.4.2" @@ -2344,6 +4141,29 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + [[package]] name = "zbus" version = "5.19.0" @@ -2369,6 +4189,7 @@ dependencies = [ "rustix 1.1.6", "serde", "serde_repr", + "tokio", "tracing", "uds_windows", "uuid", @@ -2434,12 +4255,78 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa" + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "zlib-rs" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + [[package]] name = "zvariant" version = "5.15.1" @@ -2449,6 +4336,7 @@ dependencies = [ "endi", "enumflags2", "serde", + "url", "winnow", "zcheapstr", "zvariant_derive", diff --git a/packaging/desktop/launcher/Cargo.toml b/packaging/desktop/launcher/Cargo.toml index aca5bfa..47b2967 100644 --- a/packaging/desktop/launcher/Cargo.toml +++ b/packaging/desktop/launcher/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scribewatch-desktop-launcher" -version = "0.6.5" +version = "0.6.6" edition = "2024" rust-version = "1.98" @@ -15,6 +15,27 @@ winresource = "=0.1.34" tray-icon = { version = "=0.26.1", default-features = false, features = ["ksni"] } winit = { version = "=0.30.12", default-features = false, features = ["x11", "wayland"] } image = { version = "=0.25.9", default-features = false, features = ["png"] } +# Native cross-platform microphone capture extracted from Handy (MIT). +handy-recorder = "=0.1.1" +# Stream 16-kHz PCM to disk instead of storing the entire recording in RAM. +hound = "=3.5.1" +# Reuse ScribeWatch's local ASR/LLM HTTP API; these do not launch another engine. +reqwest = { version = "=0.13.4", default-features = false, features = ["blocking", "multipart", "json", "rustls"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +uuid = { version = "1", features = ["v4"] } +# Native clipboard with Wayland data-control, X11, Windows, macOS. +arboard = { version = "=3.7.0", default-features = false, features = ["wayland-data-control"] } +# Global desktop hotkeys, including the XDG GlobalShortcuts portal on KDE Wayland. +global_hotkey = { package = "wayclip-global-hotkey", version = "=0.7.0" } +# Input injection is native Rust, not OS-specific external scripts. +[target.'cfg(target_os = "linux")'.dependencies] +enigo = { version = "=0.6.1", default-features = false, features = ["x11rb", "libei_tokio", "platform_specific"] } + +[target.'cfg(any(target_os = "windows", target_os = "macos"))'.dependencies] +enigo = { version = "=0.6.1", default-features = false } + + [target.'cfg(windows)'.dependencies] winreg = "=0.55.0" diff --git a/packaging/desktop/launcher/src/desktop_tray.rs b/packaging/desktop/launcher/src/desktop_tray.rs index 284cb1d..98c79da 100644 --- a/packaging/desktop/launcher/src/desktop_tray.rs +++ b/packaging/desktop/launcher/src/desktop_tray.rs @@ -7,10 +7,16 @@ use std::{ time::{Duration, Instant}, }; +use super::native_dictation::{NativeDictation, transcribe_to_clipboard}; +use global_hotkey::{ + GlobalHotKeyEvent, GlobalHotKeyManager, HotKeyState, + hotkey::{Code, HotKey, Modifiers}, +}; use tray_icon::{ Icon, TrayIcon, TrayIconBuilder, menu::{Menu, MenuEvent, MenuItem}, }; +use uuid::Uuid; use winit::{ event::{Event, StartCause}, event_loop::{ControlFlow, EventLoop}, @@ -23,12 +29,35 @@ use super::open_browser; enum Signal { Menu(MenuEvent), Show, + DictationToggle, + DictationFinished(Result), } fn show_file(base: &Path) -> PathBuf { base.join("tray-ipc.port") } +fn token_file(base: &Path) -> PathBuf { + base.join("tray-ipc.token") +} + +pub fn request_dictation(base: &Path) -> Result<(), String> { + let port = fs::read_to_string(show_file(base)).map_err(|e| e.to_string())?; + let token = fs::read_to_string(token_file(base)).map_err(|e| e.to_string())?; + let port: u16 = port + .trim() + .parse() + .map_err(|e: std::num::ParseIntError| e.to_string())?; + let socket = UdpSocket::bind("127.0.0.1:0").map_err(|e| e.to_string())?; + socket + .send_to( + format!("DICTATE:{}", token.trim()).as_bytes(), + ("127.0.0.1", port), + ) + .map_err(|e| e.to_string())?; + Ok(()) +} + pub fn request_show(base: &Path) { // The only accepted IPC action makes the existing tray visible again. if let Ok(port) = fs::read_to_string(show_file(base)) @@ -143,18 +172,29 @@ pub fn run(port: u16, base: PathBuf, mut child: Child) -> Result<(), String> { let socket = UdpSocket::bind("127.0.0.1:0").map_err(|e| e.to_string())?; let ipc_port = socket.local_addr().map_err(|e| e.to_string())?.port(); fs::write(show_file(&base), ipc_port.to_string()).map_err(|e| e.to_string())?; + let token = Uuid::new_v4().to_string(); + fs::write(token_file(&base), &token).map_err(|e| e.to_string())?; + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + fs::set_permissions(token_file(&base), fs::Permissions::from_mode(0o600)) + .map_err(|e| e.to_string())?; + } let sender = event_loop.create_proxy(); thread::spawn(move || { - let mut buf = [0u8; 32]; + let mut buf = [0u8; 128]; while let Ok((count, _)) = socket.recv_from(&mut buf) { if &buf[..count] == b"SHOW" { let _ = sender.send_event(Signal::Show); + } else if &buf[..count] == format!("DICTATE:{token}").as_bytes() { + let _ = sender.send_event(Signal::DictationToggle); } } }); let menu = Menu::new(); let open = MenuItem::new("Ouvrir ScribeWatch", true, None); + let dictate = MenuItem::new("Démarrer la dictée", true, None); let startup = MenuItem::new("Lancement automatique", true, None); let hide = MenuItem::new( "Masquer l'icône (jusqu'à la prochaine ouverture)", @@ -162,7 +202,7 @@ pub fn run(port: u16, base: PathBuf, mut child: Child) -> Result<(), String> { None, ); let quit = MenuItem::new("Quitter ScribeWatch", true, None); - menu.append_items(&[&open, &startup, &hide, &quit]) + menu.append_items(&[&open, &dictate, &startup, &hide, &quit]) .map_err(|e| e.to_string())?; startup.set_text(if autostart_enabled() { "Désactiver le lancement automatique" @@ -172,8 +212,27 @@ pub fn run(port: u16, base: PathBuf, mut child: Child) -> Result<(), String> { let image = application_icon()?; let mut tray: Option = None; let mut last_health = Instant::now(); + // Different from browser-only Ctrl+Shift+D to avoid duplicate toggles + // when the browser is focused and the global shortcut is pressed. + let shortcut = HotKey::new(Some(Modifiers::CONTROL | Modifiers::ALT), Code::KeyD); + let hotkey_manager = GlobalHotKeyManager::new().ok(); + let hotkey_registered = hotkey_manager + .as_ref() + .is_some_and(|manager| manager.register(shortcut).is_ok()); + if hotkey_registered { + let proxy = event_loop.create_proxy(); + GlobalHotKeyEvent::set_event_handler(Some(move |event: GlobalHotKeyEvent| { + if event.id == shortcut.id() && event.state == HotKeyState::Pressed { + let _ = proxy.send_event(Signal::DictationToggle); + } + })); + } + let event_proxy = event_loop.create_proxy(); + let mut dictation: Option = None; + let mut processing = false; event_loop .run(move |event, target| { + let _keep_global_shortcut_registered = &hotkey_manager; target.set_control_flow(ControlFlow::WaitUntil( Instant::now() + Duration::from_secs(2), )); @@ -198,9 +257,67 @@ pub fn run(port: u16, base: PathBuf, mut child: Child) -> Result<(), String> { let _ = icon.set_visible(true); } } + Event::UserEvent(Signal::DictationToggle) => { + if processing { + eprintln!("ScribeWatch dictation already transcribing"); + } else if let Some(recording) = dictation.take() { + let _ = dictate.set_text("Transcription en cours…"); + processing = true; + match recording.stop() { + Ok(audio) => { + let sender = event_proxy.clone(); + thread::spawn(move || { + let result = transcribe_to_clipboard(port, audio); + let _ = sender.send_event(Signal::DictationFinished(result)); + }); + } + Err(error) => { + eprintln!("ScribeWatch dictation: {error}"); + processing = false; + let _ = dictate.set_text("Démarrer la dictée"); + } + } + } else { + match NativeDictation::start(&base) { + Ok(recording) => { + dictation = Some(recording); + let _ = dictate.set_text("Arrêter la dictée"); + if let Some(icon) = &tray { + let _ = icon + .set_tooltip(Some("ScribeWatch — dictée micro en cours")); + } + } + Err(error) => { + eprintln!("ScribeWatch microphone: {error}"); + } + } + } + } + Event::UserEvent(Signal::DictationFinished(outcome)) => { + processing = false; + let _ = dictate.set_text("Démarrer la dictée"); + match outcome { + Ok(message) => { + if let Some(icon) = &tray { + let _ = icon.set_tooltip(Some(&message)); + } + } + Err(error) => { + eprintln!("ScribeWatch transcription: {error}"); + if let Some(icon) = &tray { + let _ = icon.set_tooltip(Some(&format!( + "ScribeWatch — {}", + error.chars().take(180).collect::() + ))); + } + } + } + } Event::UserEvent(Signal::Menu(event)) => { if event.id == open.id() { let _ = open_browser(port); + } else if event.id == dictate.id() { + let _ = event_proxy.send_event(Signal::DictationToggle); } else if event.id == startup.id() { if let Err(err) = set_autostart(!autostart_enabled()) { eprintln!("Startup preference failed: {err}"); @@ -225,9 +342,15 @@ pub fn run(port: u16, base: PathBuf, mut child: Child) -> Result<(), String> { } } Event::LoopExiting => { + if let Some(active) = dictation.take() { + if let Err(error) = active.stop() { + eprintln!("ScribeWatch dictation recovery: {error}"); + } + } let _ = child.kill(); let _ = child.wait(); let _ = fs::remove_file(show_file(&base)); + let _ = fs::remove_file(token_file(&base)); } _ => {} } diff --git a/packaging/desktop/launcher/src/main.rs b/packaging/desktop/launcher/src/main.rs index bd9e4ba..2b042c6 100644 --- a/packaging/desktop/launcher/src/main.rs +++ b/packaging/desktop/launcher/src/main.rs @@ -4,7 +4,7 @@ use std::{ env, fs::{self, File, OpenOptions}, io::{Read, Write}, - net::{SocketAddr, TcpStream}, + net::{SocketAddr, TcpListener, TcpStream}, path::{Path, PathBuf}, process::{Command, Stdio}, thread, @@ -44,6 +44,7 @@ fn show_error(message: &str) { } mod desktop_tray; +mod native_dictation; const APP_NAME: &str = "ScribeWatch"; const APP_ENV: &str = "SCRIBEWATCH"; @@ -184,6 +185,53 @@ fn open_browser(port: u16) -> Result<(), String> { } } +/// Choose loopback ports using the OS. Never probe another program's API. +fn available_port(preferred: u16, forbidden: &[u16]) -> Result { + if preferred != 0 + && !forbidden.contains(&preferred) + && let Ok(listener) = TcpListener::bind(("127.0.0.1", preferred)) + { + return Ok(listener.local_addr().map_err(|e| e.to_string())?.port()); + } + for _ in 0..12 { + let listener = TcpListener::bind(("127.0.0.1", 0)).map_err(|e| e.to_string())?; + let port = listener.local_addr().map_err(|e| e.to_string())?.port(); + if !forbidden.contains(&port) { + return Ok(port); + } + } + Err("No available loopback port for ScribeWatch".into()) +} + +fn installed_port_file(base: &Path) -> PathBuf { + base.join("server.port") +} + +fn read_installed_port(base: &Path) -> Option { + fs::read_to_string(installed_port_file(base)) + .ok() + .and_then(|s| s.trim().parse::().ok()) + .filter(|port| *port != 0) +} + +fn persist_installed_port(base: &Path, port: u16) -> Result<(), String> { + let tmp = base.join(format!("server.port.{}.tmp", std::process::id())); + fs::write(&tmp, format!("{port}\n")).map_err(|e| e.to_string())?; + let dest = installed_port_file(base); + #[cfg(target_os = "windows")] + if dest.is_file() { + // Windows rename does not replace an existing target. + fs::remove_file(&dest).map_err(|e| e.to_string())?; + } + fs::rename(&tmp, dest).map_err(|e| e.to_string()) +} + +fn desktop_engine_ports(main_port: u16) -> Result<(u16, u16), String> { + let stt = available_port(38005, &[main_port])?; + let llm = available_port(38080, &[main_port, stt])?; + Ok((stt, llm)) +} + fn launch(smoke: bool, no_browser: bool) -> Result<(), String> { let root = resources()?; let server = root.join("bin").join(executable(SERVER_NAME)); @@ -221,24 +269,34 @@ fn launch(smoke: bool, no_browser: bool) -> Result<(), String> { for folder in [&base, &config, &data, &fonts] { fs::create_dir_all(folder).map_err(|e| format!("{}: {e}", folder.display()))?; } - let port = env::var(format!("{APP_ENV}_PORT")) + let preferred = env::var(format!("{APP_ENV}_PORT")) .ok() .and_then(|value| value.parse::().ok()) + .filter(|port| *port != 0) .unwrap_or(DEFAULT_PORT); - if http_health(port).is_ok() { - if smoke { - return Err("A server already occupies the smoke test port".into()); - } - // A second launch restores the hidden tray without restarting the backend. - desktop_tray::request_show(&base); - if !no_browser { - open_browser(port)?; + // Find our previously launched backend even if its preferred port was + // already occupied by another service at first installation. + let previous = read_installed_port(&base); + for port in [previous, Some(preferred)].into_iter().flatten() { + if http_health(port).is_ok() { + if env::args().any(|arg| arg == "--dictate-toggle") { + return desktop_tray::request_dictation(&base); + } + if smoke { + return Err("A server already occupies the smoke test port".into()); + } + desktop_tray::request_show(&base); + if !no_browser { + open_browser(port)?; + } + return Ok(()); } - return Ok(()); } - if TcpStream::connect(SocketAddr::from(([127, 0, 0, 1], port))).is_ok() { - return Err(format!("Port {port} is used by another application")); + if env::args().any(|arg| arg == "--dictate-toggle") { + return Err("ScribeWatch doit être lancé avant une dictée globale".into()); } + let port = available_port(preferred, &[])?; + let (stt_port, llm_port) = desktop_engine_ports(port)?; let path = env::var_os("PATH").unwrap_or_default(); let path = env::join_paths(std::iter::once(root.join("bin")).chain(env::split_paths(&path))) @@ -267,6 +325,8 @@ fn launch(smoke: bool, no_browser: bool) -> Result<(), String> { .env("SCRIBEWATCH_NATIVE_AUTOINIT", if smoke { "0" } else { "1" }) .env("SCRIBEWATCH_EMBEDDED_DIR", root.join("bin").join("engines")) .env(format!("{APP_ENV}_PORT"), port.to_string()) + .env("SCRIBEWATCH_STT_PORT", stt_port.to_string()) + .env("SCRIBEWATCH_LLM_PORT", llm_port.to_string()) .env(format!("{APP_ENV}_CONFIG_DIR"), &config) .env(format!("{APP_ENV}_DATA_DIR"), &data) .env(format!("{APP_ENV}_DIST_DIR"), &frontend) @@ -295,6 +355,9 @@ fn launch(smoke: bool, no_browser: bool) -> Result<(), String> { logpath.display() )); } + if !smoke { + persist_installed_port(&base, port)?; + } if smoke { child.kill().map_err(|e| e.to_string())?; child.wait().map_err(|e| e.to_string())?; @@ -325,6 +388,40 @@ fn launch(smoke: bool, no_browser: bool) -> Result<(), String> { Ok(()) } +#[cfg(test)] +mod port_tests { + use super::*; + #[test] + fn occupied_primary_and_engine_ports_select_loopback_fallbacks() { + let taken_app = TcpListener::bind(("127.0.0.1", 0)).unwrap(); + let app_port = taken_app.local_addr().unwrap().port(); + let chosen = available_port(app_port, &[]).unwrap(); + assert_ne!(chosen, app_port); + let stt_busy = TcpListener::bind(("127.0.0.1", 38005)).ok(); + let llm_busy = TcpListener::bind(("127.0.0.1", 38080)).ok(); + let (stt, llm) = desktop_engine_ports(chosen).unwrap(); + assert_ne!(stt, llm); + assert_ne!(stt, chosen); + assert_ne!(llm, chosen); + if stt_busy.is_some() { + assert_ne!(stt, 38005); + } + if llm_busy.is_some() { + assert_ne!(llm, 38080); + } + assert!(TcpListener::bind(("127.0.0.1", stt)).is_ok()); + assert!(TcpListener::bind(("127.0.0.1", llm)).is_ok()); + } + #[test] + fn persisted_port_is_recovered_without_guessing_default() { + let path = std::env::temp_dir().join(format!("scribe-port-test-{}", uuid::Uuid::new_v4())); + fs::create_dir(&path).unwrap(); + persist_installed_port(&path, 45981).unwrap(); + assert_eq!(read_installed_port(&path), Some(45981)); + fs::remove_dir_all(path).unwrap(); + } +} + fn main() { let smoke = env::args().any(|arg| arg == "--smoke"); let no_browser = env::args().any(|arg| arg == "--no-browser"); diff --git a/packaging/desktop/launcher/src/native_dictation.rs b/packaging/desktop/launcher/src/native_dictation.rs new file mode 100644 index 0000000..9d13570 --- /dev/null +++ b/packaging/desktop/launcher/src/native_dictation.rs @@ -0,0 +1,286 @@ +//! Native Rust microphone capture and dictation transport. +//! Uses Handy's MIT-licensed handy-recorder; never accumulates a long +//! recording in memory, starts no extra engine, and imposes no time limit. +use enigo::{Direction, Enigo, Key, Keyboard, Settings}; +use handy_recorder::{AudioChunk, Recorder, RecorderConfig, Sink}; +use hound::{SampleFormat, WavSpec, WavWriter}; +use serde::Deserialize; +use std::{ + fs::{self, File, OpenOptions}, + io::BufWriter, + path::{Path, PathBuf}, + time::Duration, +}; +use uuid::Uuid; + +struct WavSink { + writer: Option>>, + error: Option, + frames: u64, +} + +impl WavSink { + fn create(path: &Path) -> Result { + let mut options = OpenOptions::new(); + options.write(true).create_new(true); + #[cfg(unix)] + { + use std::os::unix::fs::OpenOptionsExt; + options.mode(0o600); + } + let file = options.open(path).map_err(|e| e.to_string())?; + let spec = WavSpec { + channels: 1, + sample_rate: 16_000, + bits_per_sample: 16, + sample_format: SampleFormat::Int, + }; + let writer = WavWriter::new(BufWriter::new(file), spec).map_err(|e| e.to_string())?; + Ok(Self { + writer: Some(writer), + error: None, + frames: 0, + }) + } + + fn finish(mut self) -> Result { + if let Some(writer) = self.writer.take() { + writer.finalize().map_err(|e| e.to_string())?; + } + if let Some(error) = self.error.take() { + return Err(format!("Microphone write failure: {error}")); + } + if self.frames == 0 { + return Err("Microphone captured no audio".into()); + } + Ok(self.frames) + } +} + +impl Sink for WavSink { + fn process_chunk(&mut self, chunk: AudioChunk<'_>) { + if self.error.is_some() { + return; + } + if chunk.sample_rate != 16_000 || chunk.channels != 1 { + self.error = Some(format!( + "Unexpected microphone stream: {} Hz {} channel(s)", + chunk.sample_rate, chunk.channels + )); + return; + } + let Some(writer) = self.writer.as_mut() else { + return; + }; + for sample in chunk.samples.iter().take(chunk.valid_frames) { + let pcm = (sample.clamp(-1.0, 1.0) * 32767.0).round() as i16; + if let Err(error) = writer.write_sample(pcm) { + self.error = Some(error.to_string()); + return; + } + } + self.frames += chunk.valid_frames as u64; + } +} + +pub struct NativeDictation { + recorder: Recorder, + path: PathBuf, +} + +impl NativeDictation { + pub fn start(base: &Path) -> Result { + let directory = base.join("data/dictation-recovery"); + fs::create_dir_all(&directory).map_err(|e| e.to_string())?; + // Remove only old temporary failed dictations. A successful ASR + // already deletes its WAV. No timer, polling job or extra service. + let expiry = std::time::SystemTime::now() + .checked_sub(Duration::from_secs(24 * 3600)); + if let Some(expiry) = expiry { + if let Ok(entries) = fs::read_dir(&directory) { + for entry in entries.flatten() { + if entry.path().extension().is_some_and(|ext| ext == "wav") + && entry.metadata().ok() + .and_then(|m| m.modified().ok()) + .is_some_and(|time| time < expiry) + { + let _ = fs::remove_file(entry.path()); + } + } + } + } + let path = directory.join(format!("{}.wav", Uuid::new_v4())); + let sink = WavSink::create(&path)?; + let recorder = Recorder::open_with_failure_handler(RecorderConfig::speech(), |e| { + eprintln!("ScribeWatch microphone device error: {e}"); + }) + .map_err(|e| { + let _ = fs::remove_file(&path); + e.to_string() + })?; + if let Err(e) = recorder.start(sink) { + let _ = fs::remove_file(&path); + return Err(e.to_string()); + } + Ok(Self { recorder, path }) + } + + pub fn stop(self) -> Result { + let completed = self.recorder.stop().map_err(|e| e.to_string())?; + let end_reason = completed.end_reason.clone(); + let dropped_frames = completed.dropped_frames; + let frames = completed.sink.finish()?; + if dropped_frames > 0 || !matches!(end_reason, handy_recorder::EndReason::StopCalled) { + return Err(format!( + "Incomplete microphone recording: {frames} samples, {dropped_frames} dropped frames, {end_reason:?}. Recovery audio: {}", + self.path.display() + )); + } + Ok(self.path) + } +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +struct DictationSettings { + #[serde(default)] + structure_profile_id: Option, +} +#[derive(Deserialize)] +struct Transcript { + text: String, +} +#[derive(Deserialize)] +struct Structured { + markdown: String, +} + +fn preserve_transcript_on_structure_failure( + original: String, + structured: Result, +) -> String { + match structured { + Ok(markdown) if !markdown.trim().is_empty() => markdown, + Ok(_) => original, + Err(error) => { + eprintln!("ScribeWatch optional LLM unavailable, preserving transcript: {error}"); + original + } + } +} + +/// Called only after native microphone has stopped. WAV streams from disk +/// to localhost; the existing backend chooses the saved local/remote model. +pub fn transcribe_to_clipboard(port: u16, file: PathBuf) -> Result { + let base = format!("http://127.0.0.1:{port}"); + let client = reqwest::blocking::Client::builder() + .connect_timeout(Duration::from_secs(5)) + .build() + .map_err(|e| e.to_string())?; + let settings: DictationSettings = client + .get(format!("{base}/api/v1/dictation/settings")) + .send() + .map_err(|e| e.to_string())? + .error_for_status() + .map_err(|e| e.to_string())? + .json() + .map_err(|e| e.to_string())?; + let part = reqwest::blocking::multipart::Part::file(&file) + .map_err(|e| e.to_string())? + .mime_str("audio/wav") + .map_err(|e| e.to_string())?; + let form = reqwest::blocking::multipart::Form::new().part("file", part); + let transcript: Transcript = client + .post(format!("{base}/api/v1/dictation/transcribe")) + .multipart(form) + .send() + .map_err(|e| e.to_string())? + .error_for_status() + .map_err(|e| e.to_string())? + .json() + .map_err(|e| e.to_string())?; + let text = if let Some(profile_id) = settings.structure_profile_id.filter(|id| !id.is_empty()) { + // The LLM is optional. A cloud/local LLM failure must never discard + // a successfully recognized transcript or delay the clipboard forever. + let structured = client + .post(format!("{base}/api/v1/structure/existing")) + .json(&serde_json::json!({"profileId": profile_id, "transcript": &transcript.text})) + .send() + .and_then(|r| r.error_for_status()) + .and_then(|r| r.json::()) + .map(|r| r.markdown) + .map_err(|e| e.to_string()); + preserve_transcript_on_structure_failure(transcript.text, structured) + } else { + transcript.text + }; + if text.trim().is_empty() { + return Err("ASR returned empty text".into()); + } + let mut clipboard = arboard::Clipboard::new().map_err(|e| e.to_string())?; + clipboard.set_text(text).map_err(|e| e.to_string())?; + // Keep the transcript in the OS clipboard if key injection is unavailable + // (e.g. KDE Wayland awaiting portal permission). Never pretend it pasted. + let paste_result = paste_to_focused_application(); + // The transcript is now recoverable from the clipboard. Do not retain + // confidential recordings after a successful transcription. + if let Err(error) = fs::remove_file(&file) { + eprintln!("ScribeWatch dictation temporary audio cleanup: {error}"); + } + match paste_result { + Ok(()) => Ok("Dictée transcrite et insérée dans l’application active".into()), + Err(error) => { + eprintln!("ScribeWatch paste unavailable: {error}"); + Ok("Dictée copiée dans le presse-papiers ; collage manuel nécessaire".into()) + } + } +} + +/// Simulates the platform's paste shortcut via Rust. The target window +/// remains focused because the tray never opens a dictation window. +fn paste_to_focused_application() -> Result<(), String> { + let mut keys = Enigo::new(&Settings::default()).map_err(|e| e.to_string())?; + #[cfg(target_os = "macos")] + let modifier = Key::Meta; + #[cfg(not(target_os = "macos"))] + let modifier = Key::Control; + + keys.key(modifier, Direction::Press) + .map_err(|e| e.to_string())?; + let click = keys.key(Key::Unicode('v'), Direction::Click); + let release = keys.key(modifier, Direction::Release); + click.map_err(|e| e.to_string())?; + release.map_err(|e| e.to_string()) +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn optional_llm_failure_preserves_exact_asr_transcript() { + let original = "Texte médical exact, intégral.".to_owned(); + assert_eq!(preserve_transcript_on_structure_failure(original.clone(), Err("offline".into())), original); + assert_eq!(preserve_transcript_on_structure_failure(original.clone(), Ok(String::new())), original); + assert_eq!(preserve_transcript_on_structure_failure(original.clone(), Ok("Compte rendu IA".into())), "Compte rendu IA"); + } + + #[test] + fn long_pcm_capture_is_streamed_to_a_wav_file_without_duration_cap() { + let path = std::env::temp_dir().join(format!("scribewatch-test-{}.wav", Uuid::new_v4())); + let mut sink = WavSink::create(&path).unwrap(); + for _ in 0..1000 { + sink.process_chunk(AudioChunk { + samples: &[0.25f32; 480], + sample_rate: 16_000, + channels: 1, + valid_frames: 480, + }); + } + assert_eq!(sink.finish().unwrap(), 480_000); + let mut decoder = hound::WavReader::open(&path).unwrap(); + assert_eq!(decoder.spec().sample_rate, 16000); + assert_eq!(decoder.len(), 480_000); + assert_eq!(decoder.samples::().next().unwrap().unwrap(), 8192); + fs::remove_file(&path).unwrap(); + } +} diff --git a/packaging/desktop/test_native_first_run.py b/packaging/desktop/test_native_first_run.py index f5edb13..04ae260 100644 --- a/packaging/desktop/test_native_first_run.py +++ b/packaging/desktop/test_native_first_run.py @@ -23,6 +23,70 @@ def localhost_port(): class NativeFirstRun(unittest.TestCase): + def test_port_selection_preserves_zero_config_providers_and_custom_endpoints(self): + with tempfile.TemporaryDirectory(prefix="scribe-dynamic-native-ports-") as temp: + root=pathlib.Path(temp) + for name in ("config","data","engines","frontend"): + (root/name).mkdir() + def reserve(): + sock=socket.socket() + sock.bind(("127.0.0.1",0)) + sock.listen(3) + return sock + with reserve() as main, reserve() as stt, reserve() as llm: + main_port=main.getsockname()[1] + stt_used=stt.getsockname()[1] + llm_used=llm.getsockname()[1] + with reserve() as candidate_stt, reserve() as candidate_llm: + stt_port=candidate_stt.getsockname()[1] + llm_port=candidate_llm.getsockname()[1] + env={**os.environ, + "SCRIBEWATCH_NATIVE_AUTOINIT":"1", + "SCRIBEWATCH_DESKTOP_MODE":"1", + "SCRIBEWATCH_EMBEDDED_DIR":str(root/"engines"), + "SCRIBEWATCH_STT_PORT":str(stt_port), + "SCRIBEWATCH_LLM_PORT":str(llm_port), + } + args=[str(APP),"--host","127.0.0.1","--port",str(localhost_port()), + "--config-dir",str(root/"config"),"--data-dir",str(root/"data"), + "--dist-dir",str(root/"frontend"),"--allowed-roots",str(root/"data")] + proc=subprocess.Popen(args,env=env,stdout=subprocess.DEVNULL,stderr=subprocess.PIPE) + try: + port=int(args[args.index("--port")+1]) + base=f"http://127.0.0.1:{port}" + for _ in range(90): + self.assertIsNone(proc.poll(),"native server crashed") + try: + with urllib.request.urlopen(base+"/api/v1/ready",timeout=1) as resp: + if resp.status==200:break + except (OSError,ValueError): + time.sleep(.09) + else:self.fail("dynamic-port desktop server did not start") + def read(endpoint): + with urllib.request.urlopen(base+endpoint,timeout=3) as response: + return json.load(response) + providers=read("/api/v1/providers") + writers=read("/api/v1/llm-providers") + engines=read("/api/v1/embedded/status")["engines"] + self.assertEqual(len(providers),1) + self.assertEqual(len(writers),1) + self.assertEqual(providers[0]["transcriptionUrl"], + f"http://127.0.0.1:{stt_port}/v1/audio/transcriptions") + self.assertEqual(writers[0]["chatCompletionsUrl"], + f"http://127.0.0.1:{llm_port}/v1/chat/completions") + self.assertEqual( + {e["kind"]:e["endpoint"] for e in engines}, + {"stt":providers[0]["transcriptionUrl"],"llm":writers[0]["chatCompletionsUrl"]} + ) + self.assertEqual(main.getsockname()[1],main_port) + self.assertEqual(stt.getsockname()[1],stt_used) + self.assertEqual(llm.getsockname()[1],llm_used) + finally: + proc.terminate() + try:proc.wait(timeout=7) + except subprocess.TimeoutExpired:proc.kill();proc.wait(timeout=5) + if proc.stderr:proc.stderr.close() + def test_fresh_native_providers_and_five_profiles_without_weights(self): with tempfile.TemporaryDirectory(prefix="scribe-native-fixture-") as temp: root = pathlib.Path(temp) diff --git a/packaging/desktop/test_native_port_fallback.py b/packaging/desktop/test_native_port_fallback.py new file mode 100644 index 0000000..b942764 --- /dev/null +++ b/packaging/desktop/test_native_port_fallback.py @@ -0,0 +1,134 @@ +"""Native launcher collision regression on a real bundled Rust backend (Linux CI).""" +import json +import os +import pathlib +import shutil +import signal +import socket +import subprocess +import tempfile +import time +import unittest +import urllib.request + +ROOT = pathlib.Path(__file__).resolve().parents[2] +LAUNCHER = pathlib.Path(os.environ.get("SCRIBEWATCH_LAUNCHER_TEST_BINARY", "")) +SERVER = pathlib.Path(os.environ.get("SCRIBEWATCH_TEST_BINARY", str(ROOT / "target" / "debug" / "scribewatch"))) + + +def find_free_socket(): + sock = socket.socket() + sock.bind(("127.0.0.1", 0)) + sock.listen(8) + return sock + + +@unittest.skipUnless(os.name == "posix" and LAUNCHER.is_file() and SERVER.is_file(), + "Requires compiled native launcher and backend on POSIX") +class NativePortFallback(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory(prefix="scribe-native-ports-") + self.addCleanup(self.temp.cleanup) + self.home = pathlib.Path(self.temp.name) / "home" + self.home.mkdir() + root = pathlib.Path(self.temp.name) / "bundle" + (root / "bin").mkdir(parents=True) + # Mimic the full installer location. No engine executables: no remote + # model download, but native provider URLs are still initialized. + (root / "bin" / "engines").mkdir() + (root / "frontend").mkdir() + (root / "frontend" / "index.html").write_text("ScribeWatch") + shutil.copyfile(LAUNCHER, root / "ScribeWatch") + (root / "ScribeWatch").chmod(0o755) + (root / "bin" / "scribewatch-server").symlink_to(SERVER.resolve()) + for cmd in ("ffmpeg", "ffprobe"): + (root / "bin" / cmd).symlink_to(shutil.which(cmd)) + self.launcher = root / "ScribeWatch" + self.env = {**os.environ, "HOME": str(self.home)} + self.base = self.home / ".local/share/ScribeWatch" + + def wait_backend(self, proc): + port_file = self.base / "server.port" + for _ in range(160): + if proc.poll() is not None: + raise AssertionError(f"launcher died with {proc.returncode}; " + f"log: {(self.base/'desktop.log').read_text()[-2000:] if (self.base/'desktop.log').exists() else 'none'}") + if port_file.is_file(): + port = int(port_file.read_text().strip()) + try: + with urllib.request.urlopen(f"http://127.0.0.1:{port}/api/v1/ready", timeout=.6) as res: + if res.status == 200: + return port + except OSError: + pass + time.sleep(.12) + self.fail("ScribeWatch never became healthy on the OS-selected port") + + def start(self): + proc = subprocess.Popen([str(self.launcher), "--no-browser", "--no-tray"], + env=self.env, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, start_new_session=True) + self.addCleanup(self.stop, proc) + return proc + + @staticmethod + def stop(proc): + if proc.poll() is None: + try: + os.killpg(proc.pid, signal.SIGTERM) + proc.wait(timeout=5) + except (ProcessLookupError, subprocess.TimeoutExpired): + os.killpg(proc.pid, signal.SIGKILL) + proc.wait(timeout=5) + if proc.stdout: + proc.stdout.close() + if proc.stderr: + proc.stderr.close() + + def test_busy_application_and_engine_ports_recovered_and_persisted(self): + with find_free_socket() as busy_main, find_free_socket() as busy_stt, find_free_socket() as busy_llm: + # Bind all default engine ports if possible, simulating third-party software. + busy_default_stt = socket.socket() + busy_default_llm = socket.socket() + try: + busy_default_stt.bind(("127.0.0.1", 38005)) + busy_default_stt.listen(8) + busy_default_llm.bind(("127.0.0.1", 38080)) + busy_default_llm.listen(8) + except OSError: + busy_default_stt.close() + busy_default_llm.close() + self.skipTest("A real service owns an engine port; never interfere") + try: + preferred = busy_main.getsockname()[1] + self.env["SCRIBEWATCH_PORT"] = str(preferred) + proc = self.start() + assigned = self.wait_backend(proc) + self.assertNotEqual(assigned, preferred, "Other application's socket is preserved") + def get(path): + with urllib.request.urlopen(f"http://127.0.0.1:{assigned}{path}", timeout=4) as res: + return json.load(res) + engines = {e["kind"]: e for e in get("/api/v1/embedded/status")["engines"]} + stt = get("/api/v1/providers")[0] + llm = get("/api/v1/llm-providers")[0] + self.assertNotIn(":38005/", engines["stt"]["endpoint"]) + self.assertNotIn(":38080/", engines["llm"]["endpoint"]) + self.assertEqual(engines["stt"]["endpoint"], stt["transcriptionUrl"]) + self.assertEqual(engines["llm"]["endpoint"], llm["chatCompletionsUrl"]) + # A second launch must connect to the persisted assigned port, + # not start a duplicate, and must not touch any busy sockets. + second = subprocess.run([str(self.launcher), "--no-browser", "--no-tray"], + env=self.env, timeout=15, capture_output=True) + self.assertEqual(second.returncode, 0, second.stderr.decode(errors="replace")) + self.assertEqual(int((self.base / "server.port").read_text()), assigned) + self.assertIsNone(proc.poll()) + self.assertEqual(busy_main.getsockname()[1], preferred) + self.assertEqual(busy_default_stt.getsockname()[1], 38005) + self.assertEqual(busy_default_llm.getsockname()[1], 38080) + finally: + busy_default_stt.close() + busy_default_llm.close() + + +if __name__ == "__main__": + unittest.main() diff --git a/src/api/dictation.rs b/src/api/dictation.rs new file mode 100644 index 0000000..9fce2db --- /dev/null +++ b/src/api/dictation.rs @@ -0,0 +1,715 @@ +use crate::{ + domain::TranscriptionRoute, + error::{AppError, AppResult}, + provider, + state::AppState, +}; +use axum::{ + Json, + extract::{Multipart, State}, +}; +use serde::{Deserialize, Serialize}; +use std::{path::PathBuf, time::Instant}; +use tokio::io::AsyncWriteExt; +use tokio_util::sync::CancellationToken; +use uuid::Uuid; + +/// Dictation is stateless: no retained recording, no separate ASR process. +/// Audio streams straight to a temporary file; the existing configurable +/// ScribeWatch upload quota guards disk exhaustion without a duration cap. +const MAX_ROUTES: usize = 4; + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct DictationResult { + text: String, + provider_id: String, + model: String, + elapsed_ms: u64, +} + +const SETTINGS_KIND: &str = "dictation_settings"; +const SETTINGS_ID: &str = "desktop"; +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct DictationSettings { + pub transcription_chain: Vec, + pub language: String, + #[serde(default)] + pub structure_profile_id: Option, +} + +async fn effective_settings(state: &AppState) -> AppResult { + if let Some(saved) = state + .db + .get::(SETTINGS_KIND, SETTINGS_ID)? + { + return Ok(saved); + } + let providers = state.providers.read().await; + let first = providers + .iter() + .filter(|p| p.enabled) + .find(|p| p.model.to_ascii_lowercase().contains("parakeet")) + .or_else(|| providers.iter().find(|p| p.enabled)); + Ok(DictationSettings { + transcription_chain: first + .map(|p| { + vec![TranscriptionRoute { + provider_id: p.id.clone(), + model: p.model.clone(), + fallback_after_seconds: None, + }] + }) + .unwrap_or_default(), + language: "fr".into(), + structure_profile_id: None, + }) +} + +pub async fn settings(State(state): State) -> AppResult> { + Ok(Json(effective_settings(&state).await?)) +} + +pub async fn save_settings( + State(state): State, + Json(settings): Json, +) -> AppResult> { + if settings.transcription_chain.is_empty() || settings.transcription_chain.len() > MAX_ROUTES { + return Err(AppError::BadRequest( + "select a valid transcription chain".into(), + )); + } + let providers = state.providers.read().await; + for route in &settings.transcription_chain { + if route.provider_id.trim().is_empty() + || route.fallback_after_seconds == Some(0) + || !providers + .iter() + .any(|p| p.enabled && p.id == route.provider_id) + { + return Err(AppError::BadRequest( + "transcription provider unavailable".into(), + )); + } + } + drop(providers); + if let Some(id) = settings + .structure_profile_id + .as_ref() + .filter(|v| !v.is_empty()) + && !state + .structure_profiles + .read() + .await + .iter() + .any(|p| p.id == *id && !p.provider_id.is_empty()) + { + return Err(AppError::BadRequest("AI profile unavailable".into())); + } + if settings.language.len() > 20 + || settings + .language + .chars() + .any(|c| !c.is_ascii_alphabetic() && c != '-') + { + return Err(AppError::BadRequest( + "invalid transcription language".into(), + )); + } + state.db.upsert(SETTINGS_KIND, SETTINGS_ID, &settings)?; + Ok(Json(settings)) +} + +struct StagedAudio(PathBuf); + +impl Drop for StagedAudio { + fn drop(&mut self) { + let _ = std::fs::remove_file(&self.0); + } +} + +fn audio_extension(mime: &str, filename: &str) -> &'static str { + let mime = mime.to_ascii_lowercase(); + if mime.contains("webm") { + return "webm"; + } + if mime.contains("mp4") || mime.contains("m4a") { + return "m4a"; + } + if mime.contains("ogg") { + return "ogg"; + } + if mime.contains("wav") { + return "wav"; + } + if mime.contains("flac") { + return "flac"; + } + match filename + .rsplit('.') + .next() + .unwrap_or("") + .to_ascii_lowercase() + .as_str() + { + "webm" => "webm", + "m4a" | "mp4" => "m4a", + "ogg" | "opus" => "ogg", + "wav" => "wav", + "flac" => "flac", + _ => "webm", + } +} + +fn parse_routes( + json: Option<&str>, + provider_id: &str, + model: &str, +) -> Result, AppError> { + let routes: Vec = match json.map(str::trim).filter(|s| !s.is_empty()) { + Some(raw) if raw.len() <= 4096 => serde_json::from_str(raw) + .map_err(|_| AppError::BadRequest("invalid transcriptionChain".into()))?, + Some(_) => return Err(AppError::BadRequest("transcriptionChain too large".into())), + None if !provider_id.trim().is_empty() => vec![TranscriptionRoute { + provider_id: provider_id.trim().to_owned(), + model: model.trim().to_owned(), + fallback_after_seconds: None, + }], + None => Vec::new(), + }; + if routes.is_empty() + || routes.len() > MAX_ROUTES + || routes + .iter() + .any(|r| r.provider_id.trim().is_empty() || r.fallback_after_seconds == Some(0)) + { + return Err(AppError::BadRequest( + "select 1 to 4 valid transcription routes".into(), + )); + } + Ok(routes) +} + +/// Multipart: file, transcriptionChain (optional), providerId, model, language. +/// Audio and transcript exist only for this request; nothing is persisted to SQLite. +pub async fn transcribe( + State(state): State, + mut multipart: Multipart, +) -> AppResult> { + let mut staged: Option = None; + let mut bytes_received = 0u64; + let mut provider_id = String::new(); + let mut model = String::new(); + let mut language = String::new(); + let mut chain = None; + while let Some(mut field) = multipart + .next_field() + .await + .map_err(|_| AppError::BadRequest("invalid dictation upload".into()))? + { + let name = field.name().unwrap_or_default().to_owned(); + if name == "file" { + if staged.is_some() { + return Err(AppError::BadRequest( + "only one audio file is accepted".into(), + )); + } + let extension = audio_extension( + field.content_type().unwrap_or(""), + field.file_name().unwrap_or(""), + ); + let path = state.config.quick_upload_dir().join(format!( + "dictation-{}.{}", + Uuid::new_v4(), + extension + )); + let mut file = tokio::fs::OpenOptions::new() + .write(true) + .create_new(true) + .open(&path) + .await + .map_err(AppError::from)?; + staged = Some(StagedAudio(path)); + while let Some(chunk) = field + .chunk() + .await + .map_err(|_| AppError::BadRequest("invalid audio data".into()))? + { + bytes_received = bytes_received.saturating_add(chunk.len() as u64); + if bytes_received > state.config.max_upload_bytes { + return Err(AppError::BadRequest( + "dictation exceeds the configured ScribeWatch upload quota".into(), + )); + } + file.write_all(&chunk).await.map_err(AppError::from)?; + } + file.flush().await.map_err(AppError::from)?; + drop(file); + } else if matches!( + name.as_str(), + "providerId" | "model" | "language" | "transcriptionChain" + ) { + let text = field + .text() + .await + .map_err(|_| AppError::BadRequest("invalid dictation option".into()))?; + if text.len() > 4096 { + return Err(AppError::BadRequest("dictation option too large".into())); + } + match name.as_str() { + "providerId" => provider_id = text, + "model" => model = text, + "language" => language = text, + "transcriptionChain" => chain = Some(text), + _ => {} + } + } + } + let file = staged.ok_or_else(|| AppError::BadRequest("audio file is required".into()))?; + if bytes_received < 128 { + return Err(AppError::BadRequest( + "audio file is empty or too short".into(), + )); + } + // Native Rust microphone submits only the audio: load all preferences + // (model selection, fallback chain AND language) from the same saved + // configuration as the browser UI. In particular, an empty language field + // breaks strict forced alignment models such as Parakeet Ultra. + let needs_routes = + chain.as_deref().is_none_or(|v| v.trim().is_empty()) && provider_id.trim().is_empty(); + let saved = if needs_routes || language.trim().is_empty() { + Some(effective_settings(&state).await?) + } else { + None + }; + let routes = if needs_routes { + saved + .as_ref() + .map(|s| s.transcription_chain.clone()) + .unwrap_or_default() + } else { + parse_routes(chain.as_deref(), &provider_id, &model)? + }; + if language.trim().is_empty() { + language = saved + .as_ref() + .map(|s| s.language.clone()) + .unwrap_or_else(|| "fr".into()); + } + if routes.is_empty() { + return Err(AppError::BadRequest( + "no transcription provider is configured".into(), + )); + } + if language.len() > 20 + || language + .chars() + .any(|c| !c.is_ascii_alphabetic() && c != '-') + { + return Err(AppError::BadRequest( + "invalid transcription language".into(), + )); + } + let available = state.providers.read().await.clone(); + // Reject an invalid/unavailable selection rather than silently routing elsewhere. + for route in &routes { + if !available + .iter() + .any(|p| p.id == route.provider_id && p.enabled) + { + return Err(AppError::BadRequest( + "selected transcription provider is unavailable".into(), + )); + } + } + let _slot = state + .transcription_slots + .clone() + .acquire_owned() + .await + .map_err(|_| AppError::Internal(anyhow::anyhow!("transcription scheduler unavailable")))?; + let started = Instant::now(); + for route in routes { + let Some(mut current) = available + .iter() + .find(|p| p.id == route.provider_id) + .cloned() + else { + continue; + }; + if let Some(seconds) = route.fallback_after_seconds { + current.timeout_seconds = current.timeout_seconds.min(seconds); + } + let selected_model = if route.model.trim().is_empty() { + current.model.clone() + } else { + route.model.trim().to_owned() + }; + let token = CancellationToken::new(); + match provider::transcribe( + ¤t, + &selected_model, + Some(&language), + &file.0, + &state.http, + &token, + ) + .await + { + Ok(text) => { + return Ok(Json(DictationResult { + text, + provider_id: current.id, + model: selected_model, + elapsed_ms: started.elapsed().as_millis().min(u64::MAX as u128) as u64, + })); + } + Err(_error) => tracing::warn!( + provider_id = %current.id, + "dictation provider failed; trying next configured route" + ), + } + } + Err(AppError::Upstream( + "all selected transcription routes failed".into(), + )) +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn detects_upload_format_without_trusting_filename_extensions() { + assert_eq!(audio_extension("audio/webm;codecs=opus", "foo.wav"), "webm"); + assert_eq!(audio_extension("audio/mp4", "foo.webm"), "m4a"); + assert_eq!(audio_extension("", "test.FLAC"), "flac"); + assert_eq!(audio_extension("", "../../untrusted.exe"), "webm"); + } + #[test] + fn checks_provider_selection_and_bounded_chain() { + assert!(parse_routes(None, "", "").is_err()); + assert!(parse_routes(Some("[]"), "", "").is_err()); + let one = parse_routes(None, "local", "").unwrap(); + assert_eq!(one[0].provider_id, "local"); + assert!( + parse_routes( + Some("[{\"providerId\":\"x\",\"model\":\"\",\"fallbackAfterSeconds\":0}]"), + "", + "" + ) + .is_err() + ); + assert!(parse_routes(Some("bad json"), "", "").is_err()); + } +} + +#[cfg(test)] +mod integration_tests { + use super::*; + use crate::{config::Config, domain::Provider}; + use axum::{Router, body::Bytes, routing::post}; + use reqwest::multipart::{Form, Part}; + use serde_json::{Value, json}; + + fn tiny_wav() -> Vec { + let mut bytes = vec![0u8; 44 + 16000]; + bytes[..4].copy_from_slice(b"RIFF"); + bytes[4..8].copy_from_slice(&(16036u32).to_le_bytes()); + bytes[8..12].copy_from_slice(b"WAVE"); + bytes[12..16].copy_from_slice(b"fmt "); + bytes[16..20].copy_from_slice(&16u32.to_le_bytes()); + bytes[20..22].copy_from_slice(&1u16.to_le_bytes()); + bytes[22..24].copy_from_slice(&1u16.to_le_bytes()); + bytes[24..28].copy_from_slice(&16000u32.to_le_bytes()); + bytes[28..32].copy_from_slice(&32000u32.to_le_bytes()); + bytes[32..34].copy_from_slice(&2u16.to_le_bytes()); + bytes[34..36].copy_from_slice(&16u16.to_le_bytes()); + bytes[36..40].copy_from_slice(b"data"); + bytes[40..44].copy_from_slice(&16000u32.to_le_bytes()); + bytes + } + + async fn setup() -> (tempfile::TempDir, AppState, String) { + let temp = tempfile::tempdir().unwrap(); + let root = temp.path(); + let allowed = root.join("allowed"); + std::fs::create_dir_all(&allowed).unwrap(); + let config = Config { + host: "127.0.0.1".into(), + port: 0, + config_dir: root.join("config"), + dist_dir: root.join("dist"), + data_dir: root.join("data"), + allowed_roots: vec![allowed], + scan_seconds: 1, + file_stability_ms: 20, + max_transcription_jobs: 1, + max_upload_bytes: 16 * 1024 * 1024, + quick_result_retention_hours: 24, + quick_source_retention_hours: 24, + normalized_audio_format: "wav".into(), + ffmpeg_threads: 1, + }; + let state = AppState::load(config).await.unwrap(); + let stub = Router::new() + .route( + "/v1/audio/transcriptions", + post(|_body: Bytes| async { Json(json!({"text":"bonjour dictée"})) }), + ) + .layer(axum::extract::DefaultBodyLimit::disable()); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let upstream = listener.local_addr().unwrap(); + tokio::spawn(async move { axum::serve(listener, stub).await.unwrap() }); + let provider = Provider { + id: "local-test".into(), + name: "Local test".into(), + transcription_url: format!("http://{upstream}/v1/audio/transcriptions"), + model: "fake-asr".into(), + api_key: String::new(), + timeout_seconds: 5, + enabled: true, + }; + state + .db + .upsert("provider", &provider.id, &provider) + .unwrap(); + state.providers.write().await.push(provider); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let addr = listener.local_addr().unwrap(); + let app = crate::api::router().with_state(state.clone()); + tokio::spawn(async move { axum::serve(listener, app).await.unwrap() }); + (temp, state, format!("http://{addr}")) + } + + fn form(provider: &str, file: Vec) -> Form { + Form::new() + .text("providerId", provider.to_string()) + .text("language", "fr") + .part( + "file", + Part::bytes(file) + .file_name("test.wav") + .mime_str("audio/wav") + .unwrap(), + ) + } + + #[tokio::test] + async fn direct_dictation_returns_text_with_no_persistent_job_or_audio() { + let (_tmp, state, base) = setup().await; + let before = state.db.list::("job").unwrap().len(); + let response = reqwest::Client::new() + .post(format!("{base}/api/v1/dictation/transcribe")) + .multipart(form("local-test", tiny_wav())) + .send() + .await + .unwrap(); + assert_eq!(response.status(), reqwest::StatusCode::OK); + let result: Value = response.json().await.unwrap(); + assert_eq!(result["text"], "bonjour dictée"); + assert_eq!(result["providerId"], "local-test"); + assert_eq!(result["model"], "fake-asr"); + let after = state.db.list::("job").unwrap().len(); + assert_eq!(before, after, "dictation must not create a stored job"); + assert!( + std::fs::read_dir(state.config.quick_upload_dir()) + .unwrap() + .filter_map(Result::ok) + .all(|entry| !entry + .file_name() + .to_string_lossy() + .starts_with("dictation-")), + "dictation audio must be removed after completion" + ); + } + + #[tokio::test] + async fn provider_failure_falls_back_to_the_next_selected_endpoint() { + let (_tmp, state, base) = setup().await; + let fail = Router::new().route( + "/v1/audio/transcriptions", + post(|| async { + ( + axum::http::StatusCode::SERVICE_UNAVAILABLE, + Json(json!({"error":"test"})), + ) + }), + ); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let upstream = listener.local_addr().unwrap(); + tokio::spawn(async move { axum::serve(listener, fail).await.unwrap() }); + let provider = Provider { + id: "failing-test".into(), + name: "Failing test".into(), + transcription_url: format!("http://{upstream}/v1/audio/transcriptions"), + model: "missing".into(), + api_key: String::new(), + timeout_seconds: 3, + enabled: true, + }; + state.providers.write().await.push(provider); + let chain = json!([ + {"providerId":"failing-test","model":"missing"}, + {"providerId":"local-test","model":"fake-asr"} + ]); + let response = reqwest::Client::new() + .post(format!("{base}/api/v1/dictation/transcribe")) + .multipart( + Form::new() + .text("transcriptionChain", chain.to_string()) + .part( + "file", + Part::bytes(tiny_wav()) + .file_name("test.wav") + .mime_str("audio/wav") + .unwrap(), + ), + ) + .send() + .await + .unwrap(); + assert_eq!(response.status(), reqwest::StatusCode::OK); + let result: Value = response.json().await.unwrap(); + assert_eq!(result["providerId"], "local-test"); + assert_eq!(result["text"], "bonjour dictée"); + assert!( + state + .db + .list::("job") + .unwrap() + .is_empty() + ); + } + + #[tokio::test] + async fn native_file_only_request_uses_persisted_language_and_model() { + let (_tmp, state, base) = setup().await; + let upstream = Router::new().route( + "/v1/audio/transcriptions", + post(|body: Bytes| async move { + let raw = String::from_utf8_lossy(&body); + if raw.contains(r#"name="language""#) + && raw.contains("\r\n\r\nfr\r\n") + && raw.contains(r#"name="model""#) + && raw.contains("\r\n\r\nstrict-asr\r\n") + { + ( + axum::http::StatusCode::OK, + Json(json!({"text": "français vérifié"})), + ) + } else { + ( + axum::http::StatusCode::BAD_REQUEST, + Json(json!({"error": "language or model missing"})), + ) + } + }), + ); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); + let addr = listener.local_addr().unwrap(); + tokio::spawn(async move { axum::serve(listener, upstream).await.unwrap() }); + let strict = Provider { + id: "strict-asr".into(), + name: "Forced-aligner".into(), + transcription_url: format!("http://{addr}/v1/audio/transcriptions"), + model: "strict-asr".into(), + api_key: String::new(), + timeout_seconds: 10, + enabled: true, + }; + state.providers.write().await.push(strict); + let client = reqwest::Client::new(); + let settings = json!({ + "transcriptionChain": [{"providerId": "strict-asr", "model": "strict-asr"}], + "language": "fr", "structureProfileId": null, + }); + let saved = client + .put(format!("{base}/api/v1/dictation/settings")) + .json(&settings) + .send() + .await + .unwrap(); + assert_eq!(saved.status(), reqwest::StatusCode::OK); + let retrieved: Value = client + .get(format!("{base}/api/v1/dictation/settings")) + .send() + .await + .unwrap() + .json() + .await + .unwrap(); + assert_eq!(retrieved, settings); + let answer = client + .post(format!("{base}/api/v1/dictation/transcribe")) + .multipart( + Form::new().part( + "file", + Part::bytes(tiny_wav()) + .file_name("micro.wav") + .mime_str("audio/wav") + .unwrap(), + ), + ) + .send() + .await + .unwrap(); + assert_eq!(answer.status(), reqwest::StatusCode::OK); + let result: Value = answer.json().await.unwrap(); + assert_eq!(result["text"], "français vérifié"); + assert_eq!(result["providerId"], "strict-asr"); + } + + #[tokio::test] + async fn streamed_upload_over_the_old_twelve_mib_limit_succeeds() { + let (_tmp, state, base) = setup().await; + let large = vec![0u8; 13 * 1024 * 1024]; + let result = reqwest::Client::new() + .post(format!("{base}/api/v1/dictation/transcribe")) + .multipart(form("local-test", large)) + .send() + .await + .unwrap(); + assert_eq!(result.status(), reqwest::StatusCode::OK); + assert!( + state + .db + .list::("job") + .unwrap() + .is_empty() + ); + assert!( + std::fs::read_dir(state.config.quick_upload_dir()) + .unwrap() + .filter_map(Result::ok) + .all(|e| !e.file_name().to_string_lossy().starts_with("dictation-")) + ); + } + + #[tokio::test] + async fn invalid_provider_and_oversized_body_fail_without_jobs() { + let (_tmp, state, base) = setup().await; + let client = reqwest::Client::new(); + let response = client + .post(format!("{base}/api/v1/dictation/transcribe")) + .multipart(form("missing", tiny_wav())) + .send() + .await + .unwrap(); + assert_eq!(response.status(), reqwest::StatusCode::BAD_REQUEST); + let response = client + .post(format!("{base}/api/v1/dictation/transcribe")) + .multipart(form("local-test", vec![1u8; 16 * 1024 * 1024 + 1])) + .send() + .await + .unwrap(); + assert!(matches!(response.status().as_u16(), 400 | 413)); + assert!( + state + .db + .list::("job") + .unwrap() + .is_empty() + ); + } +} diff --git a/src/api/embedded.rs b/src/api/embedded.rs index d508f1c..f8e2a65 100644 --- a/src/api/embedded.rs +++ b/src/api/embedded.rs @@ -34,6 +34,24 @@ const ID: &str = "selection"; const STT_PORT: u16 = 38005; const LLM_PORT: u16 = 38080; const MAX_BYTES: usize = 1024 * 1024; + +/// The native launcher passes ports chosen by the OS. A standalone server or +/// Docker retains its documented defaults unless explicitly configured. +fn configured_port(name: &str, default: u16) -> u16 { + std::env::var(name) + .ok() + .and_then(|value| value.parse::().ok()) + .filter(|port| *port != 0) + .unwrap_or(default) +} + +pub(crate) fn native_stt_port() -> u16 { + configured_port("SCRIBEWATCH_STT_PORT", STT_PORT) +} +pub(crate) fn native_llm_port() -> u16 { + configured_port("SCRIBEWATCH_LLM_PORT", LLM_PORT) +} + const PACK_MODELS: &[&str] = &[ "handy-computer/parakeet-ultra-gguf", "handy-computer/whisper-large-v3-turbo-gguf", @@ -248,8 +266,8 @@ pub enum EngineKind { impl EngineKind { fn port(self) -> u16 { match self { - Self::Stt => STT_PORT, - Self::Llm => LLM_PORT, + Self::Stt => native_stt_port(), + Self::Llm => native_llm_port(), } } fn name(self) -> &'static str { @@ -260,8 +278,8 @@ impl EngineKind { } fn url(self) -> String { match self { - Self::Stt => format!("http://127.0.0.1:{STT_PORT}/v1/audio/transcriptions"), - Self::Llm => format!("http://127.0.0.1:{LLM_PORT}/v1/chat/completions"), + Self::Stt => format!("http://127.0.0.1:{}/v1/audio/transcriptions", self.port()), + Self::Llm => format!("http://127.0.0.1:{}/v1/chat/completions", self.port()), } } } @@ -640,7 +658,7 @@ impl EmbeddedManager { // Request Qwen first; llama.cpp performs/resumes the full download // asynchronously while the acoustic pack is provisioned locally. let llm_model = "unsloth/Qwen3.5-4B-GGUF:Q4_K_M"; - let llm_url = format!("http://127.0.0.1:{LLM_PORT}"); + let llm_url = format!("http://127.0.0.1:{}", native_llm_port()); let cached = match client.get(format!("{llm_url}/v1/models")).send().await { Ok(response) if response.status().is_success() => response .json::() @@ -681,7 +699,7 @@ impl EmbeddedManager { // The acoustic pack CLI defaults to WHISPER, not Parakeet. Request // exactly the benchmark-validated Parakeet Ultra through the upstream // native transcribe.cpp GGUF catalog API instead. - let stt_url = format!("http://127.0.0.1:{STT_PORT}/v1/models"); + let stt_url = format!("http://127.0.0.1:{}/v1/models", native_stt_port()); let stt_ready = match client.get(&stt_url).send().await { Ok(response) if response.status().is_success() => response .json::() @@ -856,7 +874,7 @@ pub async fn status(State(state): State) -> Json) -> Op // Shared upstream-native curated ASR download used by initial desktop // provisioning and explicit model selection. No secondary downloader service. async fn install_curated_asr(client: &Client, model: &str) -> Result<(), String> { - let origin = format!("http://127.0.0.1:{STT_PORT}"); + let origin = format!("http://127.0.0.1:{}", native_stt_port()); let variants = client .post(format!("{origin}/v1/desktop-asr/variants")) .json(&json!({"source": model})) @@ -1215,7 +1235,7 @@ pub async fn download( return Ok::<_, String>(()); } let response = client - .post(format!("http://127.0.0.1:{LLM_PORT}/models")) + .post(format!("http://127.0.0.1:{}/models", native_llm_port())) .json(&json!({"model": input.model, "sidecars": []})) .send() .await diff --git a/src/api/mod.rs b/src/api/mod.rs index 03b8209..a44c54b 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,6 +1,7 @@ pub mod ai; pub mod browse; pub mod dashboard; +pub mod dictation; pub mod embedded; pub mod events; pub mod jobs; @@ -61,6 +62,14 @@ pub fn router() -> Router { .route("/api/v1/ready", get(ready)) .route("/api/v1/dashboard", get(dashboard::stats)) .route("/api/v1/events", get(events::events)) + .route( + "/api/v1/dictation/settings", + get(dictation::settings).put(dictation::save_settings), + ) + .route( + "/api/v1/dictation/transcribe", + post(dictation::transcribe).layer(axum::extract::DefaultBodyLimit::disable()), + ) .route("/api/v1/browse", get(browse::browse)) .route( "/api/v1/providers", diff --git a/src/state.rs b/src/state.rs index 021bf49..ea4b51d 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,5 +1,5 @@ use crate::{ - api::embedded::{EmbeddedManager, Mode, Modes}, + api::embedded::{EmbeddedManager, Mode, Modes, native_llm_port, native_stt_port}, config::Config, db::Database, domain::{Job, JobEvent, JobStatus, LlmProvider, Provider, StructureProfile, Workflow}, @@ -62,7 +62,10 @@ fn default_native_transcriber() -> Provider { Provider { id: AUTO_ASR_ID.into(), name: "Parakeet Ultra (local)".into(), - transcription_url: "http://127.0.0.1:38005/v1/audio/transcriptions".into(), + transcription_url: format!( + "http://127.0.0.1:{}/v1/audio/transcriptions", + native_stt_port() + ), model: "handy-computer/parakeet-ultra-gguf".into(), api_key: String::new(), timeout_seconds: 1800, @@ -74,7 +77,7 @@ fn default_native_writer() -> LlmProvider { LlmProvider { id: AUTO_LLM_ID.into(), name: "Qwen3.5-4B Q4_K_M (local)".into(), - chat_completions_url: "http://127.0.0.1:38080/v1/chat/completions".into(), + chat_completions_url: format!("http://127.0.0.1:{}/v1/chat/completions", native_llm_port()), model: "unsloth/Qwen3.5-4B-GGUF:Q4_K_M".into(), api_key: String::new(), timeout_seconds: 1200, @@ -115,6 +118,42 @@ impl AppState { providers.push(stt); llm_providers.push(llm); } + // The launcher can choose new ports after an OS restart or if another + // application reserves a formerly free port. Only our own local + // zero-config rows are adjusted; custom/external providers remain as-is. + if std::env::var("SCRIBEWATCH_NATIVE_AUTOINIT").as_deref() == Ok("1") + && std::env::var("SCRIBEWATCH_DESKTOP_MODE").as_deref() == Ok("1") + && config.host == "127.0.0.1" + { + let stt_url = default_native_transcriber().transcription_url; + for provider in &mut providers { + if provider.id == AUTO_ASR_ID + && provider.transcription_url.starts_with("http://127.0.0.1:") + && provider + .transcription_url + .ends_with("/v1/audio/transcriptions") + && provider.transcription_url != stt_url + { + provider.transcription_url = stt_url.clone(); + db.upsert("provider", &provider.id, provider)?; + } + } + let llm_url = default_native_writer().chat_completions_url; + for provider in &mut llm_providers { + if provider.id == AUTO_LLM_ID + && provider + .chat_completions_url + .starts_with("http://127.0.0.1:") + && provider + .chat_completions_url + .ends_with("/v1/chat/completions") + && provider.chat_completions_url != llm_url + { + provider.chat_completions_url = llm_url.clone(); + db.upsert("llm_provider", &provider.id, provider)?; + } + } + } // Retain legacy rows for historical jobs; expose only the five // current built-ins. Repair only obviously mojibaked built-in text, // preserving clinician-customized clean prompts and model bindings.