MCPcopy
hub / github.com/codeaashu/claude-code / call

Function call

src/commands/voice/voice.ts:16–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14const LANG_HINT_MAX_SHOWS = 2
15
16export const call: LocalCommandCall = async () => {
17 // Check auth and kill-switch before allowing voice mode
18 if (!isVoiceModeEnabled()) {
19 // Differentiate: OAuth-less users get an auth hint, everyone else
20 // gets nothing (command shouldn't be reachable when the kill-switch is on).
21 if (!isAnthropicAuthEnabled()) {
22 return {
23 type: 'text' as const,
24 value:
25 'Voice mode requires a Claude.ai account. Please run /login to sign in.',
26 }
27 }
28 return {
29 type: 'text' as const,
30 value: 'Voice mode is not available.',
31 }
32 }
33
34 const currentSettings = getInitialSettings()
35 const isCurrentlyEnabled = currentSettings.voiceEnabled === true
36
37 // Toggle OFF — no checks needed
38 if (isCurrentlyEnabled) {
39 const result = updateSettingsForSource('userSettings', {
40 voiceEnabled: false,
41 })
42 if (result.error) {
43 return {
44 type: 'text' as const,
45 value:
46 'Failed to update settings. Check your settings file for syntax errors.',
47 }
48 }
49 settingsChangeDetector.notifyChange('userSettings')
50 logEvent('tengu_voice_toggled', { enabled: false })
51 return {
52 type: 'text' as const,
53 value: 'Voice mode disabled.',
54 }
55 }
56
57 // Toggle ON — run pre-flight checks first
58 const { isVoiceStreamAvailable } = await import(
59 '../../services/voiceStreamSTT.js'
60 )
61 const { checkRecordingAvailability } = await import('../../services/voice.js')
62
63 // Check recording availability (microphone access)
64 const recording = await checkRecordingAvailability()
65 if (!recording.available) {
66 return {
67 type: 'text' as const,
68 value:
69 recording.reason ?? 'Voice mode is not available in this environment.',
70 }
71 }
72
73 // Check for API key

Callers

nothing calls this directly

Calls 13

isVoiceModeEnabledFunction · 0.85
isAnthropicAuthEnabledFunction · 0.85
getInitialSettingsFunction · 0.85
updateSettingsForSourceFunction · 0.85
logEventFunction · 0.85
isVoiceStreamAvailableFunction · 0.85
checkVoiceDependenciesFunction · 0.85
getShortcutDisplayFunction · 0.85
normalizeLanguageForSTTFunction · 0.85
getGlobalConfigFunction · 0.85

Tested by

no test coverage detected