diff --git a/Cargo.lock b/Cargo.lock index 04e7c86..a0bbd7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,6 +212,12 @@ dependencies = [ "serde", ] +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + [[package]] name = "block-buffer" version = "0.10.4" @@ -475,6 +481,20 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +[[package]] +name = "cocoa-foundation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" +dependencies = [ + "bitflags 1.3.2", + "block", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "libc", + "objc", +] + [[package]] name = "colorchoice" version = "1.0.4" @@ -507,6 +527,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation" version = "0.10.1" @@ -530,12 +560,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ "bitflags 2.9.1", - "core-foundation", - "core-graphics-types", + "core-foundation 0.10.1", + "core-graphics-types 0.2.0", "foreign-types", "libc", ] +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "libc", +] + [[package]] name = "core-graphics-types" version = "0.2.0" @@ -543,7 +584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ "bitflags 2.9.1", - "core-foundation", + "core-foundation 0.10.1", "libc", ] @@ -796,6 +837,27 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" +[[package]] +name = "dyn-clonable" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a36efbb9bfd58e1723780aa04b61aba95ace6a05d9ffabfdb0b43672552f0805" +dependencies = [ + "dyn-clonable-impl", + "dyn-clone", +] + +[[package]] +name = "dyn-clonable-impl" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8671d54058979a37a26f3511fbf8d198ba1aa35ffb202c42587d918d77213a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "dyn-clone" version = "1.0.19" @@ -1039,7 +1101,7 @@ dependencies = [ [[package]] name = "game_controller_app" -version = "5.0.0-rc.2" +version = "5.0.0-rc.2-tts" dependencies = [ "anyhow", "clap", @@ -1052,18 +1114,19 @@ dependencies = [ [[package]] name = "game_controller_core" -version = "5.0.0-rc.2" +version = "5.0.0-rc.2-tts" dependencies = [ "enum-map", "serde", "serde_with 2.3.3", "time", + "tokio", "trait_enum", ] [[package]] name = "game_controller_logs" -version = "5.0.0-rc.2" +version = "5.0.0-rc.2-tts" dependencies = [ "anyhow", "bytes", @@ -1076,7 +1139,7 @@ dependencies = [ [[package]] name = "game_controller_msgs" -version = "5.0.0-rc.2" +version = "5.0.0-rc.2-tts" dependencies = [ "anyhow", "bindgen", @@ -1086,7 +1149,7 @@ dependencies = [ [[package]] name = "game_controller_net" -version = "5.0.0-rc.2" +version = "5.0.0-rc.2-tts" dependencies = [ "anyhow", "bytes", @@ -1098,7 +1161,7 @@ dependencies = [ [[package]] name = "game_controller_runtime" -version = "5.0.0-rc.2" +version = "5.0.0-rc.2-tts" dependencies = [ "anyhow", "clap", @@ -1106,6 +1169,7 @@ dependencies = [ "game_controller_core", "game_controller_msgs", "game_controller_net", + "game_controller_tts", "network-interface", "serde", "serde_repr", @@ -1116,6 +1180,17 @@ dependencies = [ "tokio-util", ] +[[package]] +name = "game_controller_tts" +version = "5.0.0-rc.2-tts" +dependencies = [ + "anyhow", + "speech-dispatcher", + "tokio", + "tokio-util", + "tts", +] + [[package]] name = "gdk" version = "0.18.2" @@ -1561,7 +1636,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core", + "windows-core 0.61.2", ] [[package]] @@ -1977,6 +2052,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + [[package]] name = "markup5ever" version = "0.11.0" @@ -2175,6 +2259,16 @@ dependencies = [ "libc", ] +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", + "objc_exception", +] + [[package]] name = "objc-sys" version = "0.3.5" @@ -2389,6 +2483,15 @@ dependencies = [ "objc2-foundation 0.3.1", ] +[[package]] +name = "objc_exception" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" +dependencies = [ + "cc", +] + [[package]] name = "object" version = "0.36.7" @@ -2416,6 +2519,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "oxilangtag" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f3f87617a86af77fa3691e6350483e7154c2ead9f1261b75130e21ca0f8acb" +dependencies = [ + "serde", +] + [[package]] name = "pango" version = "0.18.3" @@ -3394,6 +3506,26 @@ dependencies = [ "system-deps", ] +[[package]] +name = "speech-dispatcher" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5727d53c474ba5ada07784ad7d203cf896a74854cfee0eb32376b00759eb2972" +dependencies = [ + "lazy_static", + "libc", + "speech-dispatcher-sys", +] + +[[package]] +name = "speech-dispatcher-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c3e8acdf2b1f4bb13f1813b40b52f3edf4cc94d8a55fe713a584f672a10388d" +dependencies = [ + "bindgen", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -3504,7 +3636,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e59c1f38e657351a2e822eadf40d6a2ad4627b9c25557bc1180ec1b3295ef82" dependencies = [ "bitflags 2.9.1", - "core-foundation", + "core-foundation 0.10.1", "core-graphics", "crossbeam-channel", "dispatch", @@ -3530,8 +3662,8 @@ dependencies = [ "tao-macros", "unicode-segmentation", "url", - "windows", - "windows-core", + "windows 0.61.3", + "windows-core 0.61.2", "windows-version", "x11-dl", ] @@ -3601,7 +3733,7 @@ dependencies = [ "webkit2gtk", "webview2-com", "window-vibrancy", - "windows", + "windows 0.61.3", ] [[package]] @@ -3686,7 +3818,7 @@ dependencies = [ "tauri-utils", "thiserror 2.0.12", "url", - "windows", + "windows 0.61.3", ] [[package]] @@ -3712,7 +3844,7 @@ dependencies = [ "url", "webkit2gtk", "webview2-com", - "windows", + "windows 0.61.3", "wry", ] @@ -4066,6 +4198,29 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tts" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0727c46b3181e4f84e79f970e6a78d3b4054b72b6072e969ea4f07dfa4983ae2" +dependencies = [ + "cocoa-foundation", + "core-foundation 0.9.4", + "dyn-clonable", + "jni", + "lazy_static", + "libc", + "log", + "ndk-context", + "objc", + "oxilangtag", + "speech-dispatcher", + "thiserror 1.0.69", + "wasm-bindgen", + "web-sys", + "windows 0.58.0", +] + [[package]] name = "typeid" version = "1.0.3" @@ -4409,10 +4564,10 @@ checksum = "b542b5cfbd9618c46c2784e4d41ba218c336ac70d44c55e47b251033e7d85601" dependencies = [ "webview2-com-macros", "webview2-com-sys", - "windows", - "windows-core", - "windows-implement", - "windows-interface", + "windows 0.61.3", + "windows-core 0.61.2", + "windows-implement 0.60.0", + "windows-interface 0.59.1", ] [[package]] @@ -4433,8 +4588,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ae2d11c4a686e4409659d7891791254cf9286d3cfe0eef54df1523533d22295" dependencies = [ "thiserror 2.0.12", - "windows", - "windows-core", + "windows 0.61.3", + "windows-core 0.61.2", ] [[package]] @@ -4495,6 +4650,16 @@ dependencies = [ "windows-version", ] +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core 0.58.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows" version = "0.61.3" @@ -4502,7 +4667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ "windows-collections", - "windows-core", + "windows-core 0.61.2", "windows-future", "windows-link", "windows-numerics", @@ -4514,7 +4679,20 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "windows-core", + "windows-core 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings 0.1.0", + "windows-targets 0.52.6", ] [[package]] @@ -4523,11 +4701,11 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-implement", - "windows-interface", + "windows-implement 0.60.0", + "windows-interface 0.59.1", "windows-link", - "windows-result", - "windows-strings", + "windows-result 0.3.4", + "windows-strings 0.4.2", ] [[package]] @@ -4536,11 +4714,22 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "windows-core", + "windows-core 0.61.2", "windows-link", "windows-threading", ] +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "windows-implement" version = "0.60.0" @@ -4552,6 +4741,17 @@ dependencies = [ "syn 2.0.104", ] +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "windows-interface" version = "0.59.1" @@ -4575,10 +4775,19 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "windows-core", + "windows-core 0.61.2", "windows-link", ] +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.3.4" @@ -4588,6 +4797,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result 0.2.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows-strings" version = "0.4.2" @@ -4917,8 +5136,8 @@ dependencies = [ "webkit2gtk", "webkit2gtk-sys", "webview2-com", - "windows", - "windows-core", + "windows 0.61.3", + "windows-core 0.61.2", "windows-version", "x11-dl", ] diff --git a/Cargo.toml b/Cargo.toml index 92d7d7b..77f10f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ "game_controller_logs", "game_controller_net", "game_controller_runtime", + "game_controller_tts", ] resolver = "2" @@ -20,18 +21,21 @@ game_controller_core = { path = "game_controller_core" } game_controller_msgs = { path = "game_controller_msgs" } game_controller_net = { path = "game_controller_net" } game_controller_runtime = { path = "game_controller_runtime" } +game_controller_tts = { path = "game_controller_tts" } network-interface = { version = "1" } serde = { version = "1.0", features = ["derive"] } serde_with = { version = "2.3", features = ["base64", "time_0_3"] } serde_repr = { version = "0.1" } serde_yaml = { version = "0.9" } socket2 = { version = "0.5", features = ["all"] } +speech-dispatcher = { version = "0.16.0" } tauri = { version = "2.1", features = [] } tauri-build = { version = "2.0", features = [] } time = { version = "0.3", features = ["formatting", "local-offset", "macros", "serde"] } tokio = { version = "1.0", features = ["fs", "io-util", "macros", "net", "rt", "rt-multi-thread", "sync", "time"] } tokio-util = { version = "0.7" } trait_enum = { version = "0.5" } +tts = { version = "0.26.3" } [workspace.package] authors = ["Arne Hasselbring "] @@ -39,7 +43,7 @@ edition = "2021" license = "MIT" repository = "https://github.com/RoboCup-SPL/GameController3" rust-version = "1.82" -version = "5.0.0-rc.2" +version = "5.0.0-rc.2-tts" [profile.release-dist] inherits = "release" diff --git a/frontend/src/api.js b/frontend/src/api.js index 0f92e7c..5bbfa42 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -210,6 +210,45 @@ export const syncWithBackend = async () => { } }; +// press M to toggle mute mode +// hold spacebar for hold mode +let mute = false; +let hold = false; + +document.addEventListener('keydown', function(event) { + if (event.repeat) return; + if (event.key == 'm') { + mute = !mute; + if (window.__TAURI_INTERNALS__) { + invoke("set_mute", { mute: mute }); + } else { + console.log("Set mute to " + mute); + } + } + else if (event.key == ' ') { + event.preventDefault(); + hold = true; + if (window.__TAURI_INTERNALS__) { + invoke("set_hold", { hold: hold }); + } else { + console.log("Set hold to " + hold); + } + } +}); + +document.addEventListener('keyup', function(event) { + if (event.key == ' ') { + event.preventDefault(); + hold = false; + if (window.__TAURI_INTERNALS__) { + invoke("set_hold", { hold: hold }); + } else { + console.log("Set hold to " + hold); + } + } +}); + + export const applyAction = (action) => { if (window.__TAURI_INTERNALS__) { invoke("apply_action", { action: action }); diff --git a/frontend/src/components/Launcher.jsx b/frontend/src/components/Launcher.jsx index 2e268eb..23ed9e6 100644 --- a/frontend/src/components/Launcher.jsx +++ b/frontend/src/components/Launcher.jsx @@ -3,6 +3,7 @@ import CompetitionSettings from "./launcher/CompetitionSettings"; import GameSettings from "./launcher/GameSettings"; import NetworkSettings from "./launcher/NetworkSettings"; import WindowSettings from "./launcher/WindowSettings"; +import TtsSettings from "./launcher/TtsSettings"; import { getLaunchData, launch } from "../api"; const Launcher = ({ setLaunched }) => { @@ -10,6 +11,7 @@ const Launcher = ({ setLaunched }) => { const [launchSettings, setLaunchSettings] = useState(null); const [networkInterfaces, setNetworkInterfaces] = useState(null); const [teams, setTeams] = useState(null); + const [voices, setVoices] = useState(null); const launchSettingsAreLegal = launchSettings != null && @@ -31,6 +33,7 @@ const Launcher = ({ setLaunched }) => { setLaunchSettings(data.defaultSettings); setNetworkInterfaces(data.networkInterfaces); setTeams(data.teams); + setVoices(data.voices); }); }, []); @@ -38,7 +41,8 @@ const Launcher = ({ setLaunched }) => { competitions != null && launchSettings != null && networkInterfaces != null && - teams != null + teams != null && + voices != null ) { const setCompetition = (competition) => { const INVISIBLES_NUMBER = 0; @@ -69,6 +73,7 @@ const Launcher = ({ setLaunched }) => { const teamsInThisCompetition = teams.filter((team) => thisCompetition.teams.includes(team.number) ); + const languages = Object.keys(voices).sort() return (
{ network={launchSettings.network} setNetwork={(network) => setLaunchSettings({ ...launchSettings, network: network })} /> + setLaunchSettings({ ...launchSettings, tts: tts })} + />