Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

voice: speak French, get answers in English (and Coucou offers to switch)

Claude6490b0a11d3c
diff --git a/NotchBuddy/Resources/Localizable.xcstrings b/NotchBuddy/Resources/Localizable.xcstrings
index 6ae6b38b..797533bc 100644
--- a/NotchBuddy/Resources/Localizable.xcstrings
+++ b/NotchBuddy/Resources/Localizable.xcstrings
@@ -24978,61 +24978,61 @@
"ar": {
"stringUnit": {
"state": "translated",
- "value": "لغة الصوت"
+ "value": "Coucou يجيب بـ"
}
},
"bn": {
"stringUnit": {
"state": "translated",
- "value": "কণ্ঠের ভাষা"
+ "value": "Coucou উত্তর দেয়"
}
},
"en": {
"stringUnit": {
"state": "translated",
- "value": "Voice language"
+ "value": "Coucou answers in"
}
},
"es": {
"stringUnit": {
"state": "translated",
- "value": "Idioma de la voz"
+ "value": "Coucou responde en"
}
},
"fr": {
"stringUnit": {
"state": "translated",
- "value": "Langue de la voix"
+ "value": "Coucou répond en"
}
},
"hi": {
"stringUnit": {
"state": "translated",
- "value": "आवाज़ की भाषा"
+ "value": "Coucou जवाब देता है"
}
},
"id": {
"stringUnit": {
"state": "translated",
- "value": "Bahasa suara"
+ "value": "Coucou menjawab dalam"
}
},
"pt-BR": {
"stringUnit": {
"state": "translated",
- "value": "Idioma da voz"
+ "value": "Coucou responde em"
}
},
"ru": {
"stringUnit": {
"state": "translated",
- "value": "Язык голоса"
+ "value": "Coucou отвечает на"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
- "value": "语音语言"
+ "value": "Coucou 回答语言"
}
}
}
@@ -25556,6 +25556,136 @@
}
}
}
+ },
+ "voice.listen-language": {
+ "extractionState": "manual",
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "أنت تتحدث"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "তুমি বলো"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "You speak"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Tú hablas"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Tu parles"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "आप बोलते हैं"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Kamu berbicara"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Você fala"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Ты говоришь"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "你说的语言"
+ }
+ }
+ }
+ },
+ "voice.listen-auto": {
+ "extractionState": "manual",
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "تلقائي (لغة الإملاء في الماك)"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "স্বয়ংক্রিয় (Mac-এর ডিক্টেশনের ভাষা)"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Automatic (your Mac’s dictation language)"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Automático (idioma de dictado del Mac)"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Automatique (langue de dictée du Mac)"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "स्वचालित (Mac की डिक्टेशन भाषा)"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Otomatis (bahasa dikte Mac)"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Automático (idioma de ditado do Mac)"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Автоматически (язык диктовки Mac)"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "自动(Mac 听写语言)"
+ }
+ }
+ }
}
},
"version": "1.0"
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index a90b54d6..968e357b 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -1350,7 +1350,8 @@ extension IslandWindowController {
let runner = VoiceActionRunner.shared
// Propagate recognition locale so responses are in the spoken language.
- runner.commandLocale = VoiceEngine.shared.speechLocale
+ // Answers in the answer language, whatever language I spoke.
+ runner.commandLocale = VoiceSettings.answerLocale
// ── Conversation end phrase ────────────────────────────────────────────────
let normTranscript = WakePhrase.normalise(transcript)
@@ -1451,7 +1452,7 @@ extension IslandWindowController {
}
// ── Single command ─────────────────────────────────────────────────────────
- let locale = VoiceEngine.shared.speechLocale
+ let locale = VoiceSettings.answerLocale
let tParseEnd = Date()
let parseMs = Int(tParseEnd.timeIntervalSince(t0) * 1000)
@@ -1639,7 +1640,7 @@ extension IslandWindowController {
let asks = Self.isQuestion(result)
let speaker = VoiceSpeaker.shared
if VoiceSettings.speakEnabled {
- speaker.speak(result.message, locale: VoiceEngine.shared.speechLocale)
+ speaker.speak(result.message, locale: VoiceSettings.answerLocale)
speaker.onDidFinish = { [weak self] in
Task { @MainActor in self?.finishVoiceTurn(expectAnswer: asks) }
}
@@ -1679,6 +1680,26 @@ extension IslandWindowController {
/// Listen once for the reply to Coucou's question, or close the turn.
@MainActor
private func finishVoiceTurn(expectAnswer: Bool) {
+ // First time I speak one language and Coucou answers in another: offer once to
+ // answer in mine ("You're speaking French. Want me to answer in French?").
+ if !expectAnswer, !VoiceSettings.languageOfferDone,
+ let spoken = VoiceEngine.shared.speechLocale?.language.languageCode?.identifier,
+ ["fr", "en"].contains(spoken), spoken != VoiceSettings.language,
+ VoiceEngine.shared.isEnabled {
+ VoiceSettings.languageOfferDone = true
+ let offer = VoiceActionRunner.shared.offerLanguageSwitch(to: spoken)
+ VoiceCaptionManager.shared.appendResponse(offer)
+ let speaker = VoiceSpeaker.shared
+ if VoiceSettings.speakEnabled {
+ speaker.speak(offer, locale: VoiceSettings.answerLocale)
+ speaker.onDidFinish = {
+ Task { @MainActor in VoiceEngine.shared.startListeningDirectly(firstWordTimeout: 5.0) }
+ }
+ } else {
+ VoiceEngine.shared.startListeningDirectly(firstWordTimeout: 5.0)
+ }
+ return
+ }
// One follow-up only: the reply to a question closes the turn after it is handled
// (unless that reply leads to another question, e.g. "which one do I remove?").
if expectAnswer && VoiceEngine.shared.isEnabled {
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index 544444ed..02cf5ef5 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -1263,6 +1263,7 @@ struct SettingsView: View {
@AppStorage("voiceWeatherEnabled") private var weatherEnabled: Bool = false
@AppStorage("voiceWeatherCity") private var weatherCity: String = ""
@AppStorage("voiceLanguage") private var voiceLanguage: String = "en"
+ @AppStorage("voiceListenLanguage") private var listenLanguage: String = "auto"
@AppStorage("voiceTTSEngine") private var ttsEngine: String = "system"
@AppStorage("voiceElevenGender") private var elevenGender: String = "female"
@State private var elevenKeyDraft: String = ""
@@ -1274,12 +1275,20 @@ struct SettingsView: View {
Toggle(String(localized: "Enable voice command"), isOn: $voiceEngine.isEnabled)
.disabled(!voicePermissionsGranted && !voiceEngine.isEnabled)
+ Picker(String(localized: "voice.listen-language"), selection: $listenLanguage) {
+ Text(String(localized: "voice.listen-auto")).tag("auto")
+ Text(verbatim: "English").tag("en")
+ Text(verbatim: "Français").tag("fr")
+ }
+ .frame(maxWidth: 320)
+ .onChange(of: listenLanguage) { _, _ in VoiceEngine.shared.reloadLanguage() }
+
Picker(String(localized: "voice.language"), selection: $voiceLanguage) {
Text(verbatim: "English").tag("en")
Text(verbatim: "Français").tag("fr")
}
- .frame(maxWidth: 260)
- .onChange(of: voiceLanguage) { _, _ in VoiceEngine.shared.reloadLanguage() }
+ .frame(maxWidth: 320)
+ .onChange(of: voiceLanguage) { _, _ in VoiceBrain.shared.endConversation() }
Toggle(String(localized: "voice.setting-speak"), isOn: $speakEnabled)
diff --git a/NotchBuddy/Sources/App/Voice/LiveVoiceControls.swift b/NotchBuddy/Sources/App/Voice/LiveVoiceControls.swift
index c9d44656..d4e6bb57 100644
--- a/NotchBuddy/Sources/App/Voice/LiveVoiceControls.swift
+++ b/NotchBuddy/Sources/App/Voice/LiveVoiceControls.swift
@@ -92,6 +92,10 @@ extension VoiceActionRunner {
music = LiveMusicControl()
pills = LivePillControl()
info = LiveVoiceInfo.shared
+ onLanguageSwitch = { lang in
+ VoiceSettings.language = lang // Settings picker follows (same key)
+ VoiceBrain.shared.endConversation() // next session gets the new instructions
+ }
}
}
#endif
diff --git a/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift b/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift
index f703d41f..a6a9cb93 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift
@@ -98,6 +98,9 @@ final class VoiceActionRunner {
/// run() or handleAnswer(). Used to produce responses in the spoken language rather than the UI language.
var commandLocale: Locale? = nil
+ /// Called with "fr" / "en" when I accept to be answered in the language I speak.
+ var onLanguageSwitch: ((String) -> Void)?
+
init() {}
func run(_ intent: VoiceIntent,
@@ -306,6 +309,28 @@ final class VoiceActionRunner {
return ok("voice.question-cancelled")
}
+ // "Want me to answer in French?" — yes / no, in either language.
+ if case .switchLanguage(let lang) = pending.kind {
+ if Self.isYes(transcript) {
+ onLanguageSwitch?(lang)
+ commandLocale = Locale(identifier: lang == "fr" ? "fr-FR" : "en-US")
+ return .init(outcome: .success, message: lang == "fr"
+ ? "D'accord, je te réponds en français maintenant."
+ : "Sure, I'll answer in English from now on.")
+ }
+ if Self.isNo(transcript) {
+ let current = commandLocale?.language.languageCode?.identifier ?? "en"
+ return .init(outcome: .success, message: current == "fr"
+ ? "OK, je continue en français."
+ : "Okay, I'll keep answering in English.")
+ }
+ if !pending.askedAgain {
+ var again = pending; again.askedAgain = true; pendingQuestion = again
+ return .init(outcome: .question(text: pending.text), message: pending.text)
+ }
+ return fail("voice.unknown")
+ }
+
// A playlist name is free text, not a pill.
if case .whichPlaylist = pending.kind {
var name = transcript.trimmingCharacters(in: .whitespacesAndNewlines)
@@ -331,7 +356,7 @@ final class VoiceActionRunner {
}
switch pending.kind {
- case .whichPlaylist:
+ case .whichPlaylist, .switchLanguage:
return fail("voice.unknown") // handled above
case .whichPill(let add):
return await run(add ? .pillAdd(id: entity) : .pillRemove(id: entity),
@@ -352,6 +377,35 @@ final class VoiceActionRunner {
}
}
+ /// Asked once, in the current answer language, when I speak another one.
+ func offerLanguageSwitch(to lang: String) -> String {
+ let current = commandLocale?.language.languageCode?.identifier ?? "en"
+ let text: String
+ if lang == "fr" {
+ text = current == "fr" ? "Tu veux que je te réponde en français ?"
+ : "By the way, you're speaking French. Want me to answer in French?"
+ } else {
+ text = current == "fr" ? "Au fait, tu me parles en anglais. Tu veux que je te réponde en anglais ?"
+ : "Want me to answer in English?"
+ }
+ pendingQuestion = PendingVoiceQuestion(kind: .switchLanguage(to: lang), text: text)
+ return text
+ }
+
+ static func isYes(_ s: String) -> Bool {
+ let t = " " + IntentParser.normalise(s) + " "
+ if isNo(s) { return false }
+ return ["oui", "ouais", "ouai", "yes", "yeah", "yep", "sure", "ok", "okay", "d accord", "vas y",
+ "volontiers", "carrement", "please", "absolument", "bien sur", "go", "of course", "why not",
+ "pourquoi pas", "allez"].contains { t.contains(" " + $0 + " ") }
+ }
+
+ static func isNo(_ s: String) -> Bool {
+ let t = " " + IntentParser.normalise(s) + " "
+ return ["non", "no", "nope", "nah", "pas besoin", "garde", "keep", "laisse", "c est bon comme ca",
+ "stay", "reste", "don t", "dont"].contains { t.contains(" " + $0 + " ") }
+ }
+
/// "Je veux que tu ajoutes" (no pill named) → asks which pill, and listens for it.
/// Returns nil when the phrase has no add/remove verb either.
func askIfIncomplete(_ transcript: String) -> VoiceActionResult? {
diff --git a/NotchBuddy/Sources/App/Voice/VoiceBrain.swift b/NotchBuddy/Sources/App/Voice/VoiceBrain.swift
index 5b9d81e2..0d19bceb 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceBrain.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceBrain.swift
@@ -112,7 +112,7 @@ final class VoiceBrain {
static func instructions() -> String {
if VoiceSettings.language == "fr" {
return """
- Tu es Coucou, un assistant dans le notch du MacBook. Réponds toujours en français.
+ Tu es Coucou, un assistant dans le notch du MacBook. L'utilisateur peut parler anglais ou français : réponds toujours en français.
Réponds avec 1 à 2 phrases maximum. Sois direct et concis.
Ne pose une question que si tu as vraiment besoin d'une précision pour agir : une seule, courte, qui finit par « ? ». Sinon, ne finis jamais par une question.
Utilise les outils pour les pilules et la musique.
@@ -122,7 +122,7 @@ final class VoiceBrain {
"""
}
return """
- You are Coucou, an assistant living in the MacBook notch. Always answer in English.
+ You are Coucou, an assistant living in the MacBook notch. The user may speak French or English: always answer in English.
Answer in one or two short sentences. Be direct.
Only ask a question when you truly need a detail to act: one short question ending with "?". Otherwise never end with a question.
Use the tools for pills and music.
diff --git a/NotchBuddy/Sources/App/Voice/VoiceCaptionManager.swift b/NotchBuddy/Sources/App/Voice/VoiceCaptionManager.swift
index c13eeeb8..423a17e3 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceCaptionManager.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceCaptionManager.swift
@@ -206,7 +206,7 @@ struct VoiceCaptionView: View {
guard state.isListening else { return state.userLine }
// In the language Coucou speaks, not the interface language.
return state.liveLine.isEmpty
- ? VoiceActionRunner.localizedString("voice.caption-listening", locale: VoiceEngine.shared.speechLocale)
+ ? VoiceActionRunner.localizedString("voice.caption-listening", locale: VoiceSettings.answerLocale)
: state.liveLine
}
private var answer: String { state.isListening ? "" : state.responseLine }
diff --git a/NotchBuddy/Sources/App/Voice/VoiceEngine.swift b/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
index 86d5b302..1813a9fd 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
@@ -664,11 +664,14 @@ final class VoiceEngine: ObservableObject {
// MARK: - Helpers
private func suitableLocale() -> Locale? {
- // The language chosen in Settings → Voice first (English by default), then the
- // dictation languages, then the usual fallbacks.
- var candidates: [Locale] = VoiceSettings.language == "fr"
- ? [Locale(identifier: "fr-FR"), Locale(identifier: "fr-CA")]
- : [Locale(identifier: "en-US"), Locale(identifier: "en-GB"), Locale(identifier: "en-AU")]
+ // The language I speak (Settings → Voice → "You speak"): automatic = the Mac's
+ // dictation languages first. The answer language is separate (VoiceSettings.language).
+ var candidates: [Locale]
+ switch VoiceSettings.listenLanguage {
+ case "fr": candidates = [Locale(identifier: "fr-FR"), Locale(identifier: "fr-CA")]
+ case "en": candidates = [Locale(identifier: "en-US"), Locale(identifier: "en-GB"), Locale(identifier: "en-AU")]
+ default: candidates = []
+ }
candidates += MacDictation.automaticLocales()
candidates += [Locale(identifier: "en-US"), Locale(identifier: "fr-FR")]
for locale in candidates {
diff --git a/NotchBuddy/Sources/App/Voice/VoiceIntent.swift b/NotchBuddy/Sources/App/Voice/VoiceIntent.swift
index c3ad11fe..b2aa75d1 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceIntent.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceIntent.swift
@@ -69,6 +69,7 @@ struct PendingVoiceQuestion {
case removeWhich(toAdd: String) // 4-pill limit: which pill to remove to add X?
case whichPill(add: Bool) // "ajoute…" with no pill named: which one?
case whichPlaylist // "lance ma playlist": which playlist?
+ case switchLanguage(to: String) // "You're speaking French. Want me to answer in French?"
}
let kind: Kind
let text: String
diff --git a/NotchBuddy/Sources/App/Voice/VoiceSettings.swift b/NotchBuddy/Sources/App/Voice/VoiceSettings.swift
index f31ccea4..a04969e3 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceSettings.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceSettings.swift
@@ -35,11 +35,25 @@ enum VoiceSettings {
set { UserDefaults.standard.set(newValue, forKey: captionEnabledKey) }
}
- /// Language Coucou listens and answers in: "en" (default) or "fr".
+ /// Language Coucou ANSWERS in: "en" (default) or "fr".
static var language: String {
get { UserDefaults.standard.string(forKey: "voiceLanguage") ?? "en" }
set { UserDefaults.standard.set(newValue, forKey: "voiceLanguage") }
}
+ static var answerLocale: Locale { Locale(identifier: language == "fr" ? "fr-FR" : "en-US") }
+
+ /// Language Coucou LISTENS to: "auto" (the Mac's dictation language, default), "en" or "fr".
+ /// Independent from the answer language: speak French, hear English.
+ static var listenLanguage: String {
+ get { UserDefaults.standard.string(forKey: "voiceListenLanguage") ?? "auto" }
+ set { UserDefaults.standard.set(newValue, forKey: "voiceListenLanguage") }
+ }
+
+ /// Coucou already offered to answer in the language you speak (asked once).
+ static var languageOfferDone: Bool {
+ get { UserDefaults.standard.bool(forKey: "voiceLanguageOfferDone") }
+ set { UserDefaults.standard.set(newValue, forKey: "voiceLanguageOfferDone") }
+ }
/// Voice used to answer: "system" (macOS voices) or "elevenlabs" (user's API key).
static var ttsEngine: String {
diff --git a/tests/VoiceActionRunnerTests.swift b/tests/VoiceActionRunnerTests.swift
index 9b445612..39873516 100644
--- a/tests/VoiceActionRunnerTests.swift
+++ b/tests/VoiceActionRunnerTests.swift
@@ -215,6 +215,26 @@ enum VoiceActionRunnerTests {
check("playlist question pending", runner.pendingQuestion != nil, true)
runner.pendingQuestion = nil
+ // Language offer: speak French, answered in English → asked once, "oui" switches
+ var switched: String? = nil
+ runner.onLanguageSwitch = { switched = $0 }
+ runner.commandLocale = Locale(identifier: "en-US")
+ let offer = runner.offerLanguageSwitch(to: "fr")
+ check("offer is in English", offer.contains("Want me to answer in French?"), true)
+ let yes = await runner.handleAnswer("oui vas-y", availablePills: pills)
+ check("oui → switch to fr", switched, "fr")
+ check("oui → answered in French", yes.message.contains("en français"), true)
+ switched = nil
+ runner.commandLocale = Locale(identifier: "en-US")
+ _ = runner.offerLanguageSwitch(to: "fr")
+ let no = await runner.handleAnswer("non c'est bon", availablePills: pills)
+ check("non → no switch", switched == nil, true)
+ check("non → keeps English", no.message.contains("English"), true)
+ check("isYes yeah", VoiceActionRunner.isYes("yeah sure"), true)
+ check("isYes not on non", VoiceActionRunner.isYes("non"), false)
+ runner.pendingQuestion = nil
+ runner.commandLocale = nil
+
// ── Pills: add multiple ───────────────────────────────────────────────
pills_.active = ["integration_github"]
pills_.calls = []