Skip to content

Commit 6bdfe77

Browse files
kentcdoddscursoragent
authored andcommitted
fix: update default voice from "angus" to "luna" in text-to-speech functionality
- Changed the default voice for caching and initialization in the text-to-speech module to "luna" to align with the new model specifications. - Updated related test cases and mock responses to reflect the new default voice. - Adjusted comments in the code to clarify the default voice behavior.
1 parent aecf09e commit 6bdfe77

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

app/components/calls/__tests__/submit-recording-form.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ vi.mock('#app/utils/use-root-data.ts', () => ({
2020
useRootData: () => mockUseRootData(),
2121
}))
2222

23+
// In Vitest, the Vite macro plugin isn't installed, so mock the macro helper.
24+
vi.mock('vite-env-only/macros', () => ({
25+
serverOnly$: (fn: unknown) => fn,
26+
}))
27+
2328
import { RecordingForm } from '#app/routes/resources/calls/save.tsx'
2429

2530
describe('RecordingForm', () => {

app/routes/resources/calls/__tests__/text-to-speech-cache.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('/resources/calls/text-to-speech cache', () => {
8585

8686
const req1 = makeRequest({
8787
text: 'Hello from the cache test message.',
88-
voice: 'asteria',
88+
voice: 'luna',
8989
})
9090
const res1 = (await action({ request: req1 } as any)) as Response
9191
expect(res1.ok).toBe(true)
@@ -98,7 +98,7 @@ describe('/resources/calls/text-to-speech cache', () => {
9898
// Same content, different whitespace: should hit cache.
9999
const req2 = makeRequest({
100100
text: ' Hello from the cache test message. ',
101-
voice: 'asteria',
101+
voice: 'luna',
102102
})
103103
const res2 = (await action({ request: req2 } as any)) as Response
104104
expect(res2.ok).toBe(true)

app/routes/resources/calls/text-to-speech.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ export async function action({ request }: Route.ActionArgs) {
116116
const normalizedQuestionText = normalizeTextForCache(questionText)
117117
const speechText = withAiDisclosurePrefix(normalizedQuestionText)
118118
const model = getEnv().CLOUDFLARE_AI_TEXT_TO_SPEECH_MODEL
119-
// Aura defaults to "angus" when omitted; treat empty voice as that for caching.
120-
const voiceForCache = voiceRaw || 'angus'
119+
// aura-2-en defaults to "luna" when omitted; treat empty voice as that for caching.
120+
const voiceForCache = voiceRaw || 'luna'
121121
const cacheKeyPayload = JSON.stringify({
122122
v: 2,
123123
model,
@@ -310,7 +310,7 @@ export function CallKentTextToSpeech({
310310
const questionCountdownId = `${questionId}-countdown`
311311

312312
const defaultVoice = (callKentTextToSpeechVoices[0]?.id ??
313-
'asteria') as CallKentTextToSpeechVoice
313+
'luna') as CallKentTextToSpeechVoice
314314
const [voice, setVoice] =
315315
React.useState<CallKentTextToSpeechVoice>(defaultVoice)
316316
const [questionText, setQuestionText] = React.useState('')

app/utils/call-kent-text-to-speech.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,25 @@ export const callKentTextToSpeechConstraints = {
1010

1111
export const AI_VOICE_DISCLOSURE_PREFIX = `This caller's voice was generated by AI.`
1212

13+
// @cf/deepgram/aura-2-en: 3 male + 3 female voices (Deepgram featured + model default)
1314
const auraSpeakers = [
14-
'angus',
15-
'asteria',
15+
'apollo',
1616
'arcas',
1717
'orion',
18-
'orpheus',
19-
'athena',
2018
'luna',
21-
'zeus',
22-
'perseus',
23-
'helios',
24-
'hera',
25-
'stella',
19+
'andromeda',
20+
'helena',
2621
] as const
2722

2823
export type CallKentTextToSpeechVoice = (typeof auraSpeakers)[number]
2924

3025
export const callKentTextToSpeechVoices: Array<{
3126
id: CallKentTextToSpeechVoice
3227
label: string
33-
}> = [
34-
{ id: 'asteria', label: 'Asteria' },
35-
{ id: 'orion', label: 'Orion' },
36-
{ id: 'athena', label: 'Athena' },
37-
{ id: 'angus', label: 'Angus' },
38-
]
28+
}> = auraSpeakers.map((speaker) => ({
29+
id: speaker,
30+
label: speaker.charAt(0).toUpperCase() + speaker.slice(1),
31+
}))
3932

4033
export function isCallKentTextToSpeechVoice(
4134
voice: string,

app/utils/cloudflare-ai-text-to-speech.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function synthesizeSpeechWithWorkersAi({
6565
lowerModel.includes('deepgram/aura') || lowerModel.includes('aura-')
6666
? {
6767
text,
68-
// Aura defaults to "angus", but allow callers to override.
68+
// aura-2-en defaults to "luna", but allow callers to override.
6969
...(voice ? { speaker: voice } : {}),
7070
encoding: 'mp3',
7171
}

mocks/__tests__/cloudflare.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('cloudflare MSW mocks', () => {
7272
},
7373
body: JSON.stringify({
7474
text: 'Hello from the Call Kent TTS mock.',
75-
speaker: 'asteria',
75+
speaker: 'luna',
7676
encoding: 'mp3',
7777
}),
7878
},

mocks/cloudflare.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ export const cloudflareHandlers: Array<HttpHandler> = [
943943
const speaker =
944944
typeof body?.speaker === 'string' && body.speaker.trim()
945945
? body.speaker.trim()
946-
: 'angus'
946+
: 'luna'
947947
const frequencyHz = frequencyFromSpeakerAndText(speaker, text)
948948
const wav = makePcm16SineWaveWav({
949949
durationSeconds: 6,

0 commit comments

Comments
 (0)