@@ -3,27 +3,21 @@ import { z } from "zod";
3
3
4
4
export const nodeEnvSchema = z . object ( {
5
5
OPENAI_API_KEY : z . string ( ) . min ( 1 , "OpenAI API key is required" ) ,
6
+
7
+ // Core settings
6
8
ELEVENLABS_XI_API_KEY : z . string ( ) . optional ( ) ,
7
- ELEVENLABS_MODEL_ID : z . string ( ) . min ( 1 , "ElevenLabs model ID is required" ) ,
8
- ELEVENLABS_VOICE_ID : z . string ( ) . min ( 1 , "ElevenLabs voice ID is required" ) ,
9
- ELEVENLABS_VOICE_STABILITY : z
10
- . string ( )
11
- . min ( 1 , "ElevenLabs voice stability is required" ) ,
12
- ELEVENLABS_VOICE_SIMILARITY_BOOST : z
13
- . string ( )
14
- . min ( 1 , "ElevenLabs voice similarity boost is required" ) ,
15
- ELEVENLABS_VOICE_STYLE : z
16
- . string ( )
17
- . min ( 1 , "ElevenLabs voice style is required" ) ,
18
- ELEVENLABS_VOICE_USE_SPEAKER_BOOST : z
19
- . string ( )
20
- . min ( 1 , "ElevenLabs voice speaker boost setting is required" ) ,
21
- ELEVENLABS_OPTIMIZE_STREAMING_LATENCY : z
22
- . string ( )
23
- . min ( 1 , "ElevenLabs streaming latency optimization is required" ) ,
24
- ELEVENLABS_OUTPUT_FORMAT : z
25
- . string ( )
26
- . min ( 1 , "ElevenLabs output format is required" ) ,
9
+
10
+ // All other settings optional with defaults
11
+ ELEVENLABS_MODEL_ID : z . string ( ) . optional ( ) ,
12
+ ELEVENLABS_VOICE_ID : z . string ( ) . optional ( ) ,
13
+ ELEVENLABS_VOICE_STABILITY : z . string ( ) . optional ( ) ,
14
+ ELEVENLABS_VOICE_SIMILARITY_BOOST : z . string ( ) . optional ( ) ,
15
+ ELEVENLABS_VOICE_STYLE : z . string ( ) . optional ( ) ,
16
+ ELEVENLABS_VOICE_USE_SPEAKER_BOOST : z . string ( ) . optional ( ) ,
17
+ ELEVENLABS_OPTIMIZE_STREAMING_LATENCY : z . string ( ) . optional ( ) ,
18
+ ELEVENLABS_OUTPUT_FORMAT : z . string ( ) . optional ( ) ,
19
+ VITS_VOICE : z . string ( ) . optional ( ) ,
20
+ VITS_MODEL : z . string ( ) . optional ( ) ,
27
21
} ) ;
28
22
29
23
export type NodeConfig = z . infer < typeof nodeEnvSchema > ;
@@ -32,34 +26,51 @@ export async function validateNodeConfig(
32
26
runtime : IAgentRuntime
33
27
) : Promise < NodeConfig > {
34
28
try {
29
+ const voiceSettings = runtime . character . settings ?. voice ;
30
+ const elevenlabs = voiceSettings ?. elevenlabs ;
31
+
32
+ // Only include what's absolutely required
35
33
const config = {
36
34
OPENAI_API_KEY :
37
35
runtime . getSetting ( "OPENAI_API_KEY" ) ||
38
36
process . env . OPENAI_API_KEY ,
39
- ELEVENLABS_MODEL_ID :
40
- runtime . getSetting ( "ELEVENLABS_MODEL_ID" ) ||
41
- process . env . ELEVENLABS_MODEL_ID ,
42
- ELEVENLABS_VOICE_ID :
43
- runtime . getSetting ( "ELEVENLABS_VOICE_ID" ) ||
44
- process . env . ELEVENLABS_VOICE_ID ,
45
- ELEVENLABS_VOICE_STABILITY :
46
- runtime . getSetting ( "ELEVENLABS_VOICE_STABILITY" ) ||
47
- process . env . ELEVENLABS_VOICE_STABILITY ,
48
- ELEVENLABS_VOICE_SIMILARITY_BOOST :
49
- runtime . getSetting ( "ELEVENLABS_VOICE_SIMILARITY_BOOST" ) ||
50
- process . env . ELEVENLABS_VOICE_SIMILARITY_BOOST ,
51
- ELEVENLABS_VOICE_STYLE :
52
- runtime . getSetting ( "ELEVENLABS_VOICE_STYLE" ) ||
53
- process . env . ELEVENLABS_VOICE_STYLE ,
54
- ELEVENLABS_VOICE_USE_SPEAKER_BOOST :
55
- runtime . getSetting ( "ELEVENLABS_VOICE_USE_SPEAKER_BOOST" ) ||
56
- process . env . ELEVENLABS_VOICE_USE_SPEAKER_BOOST ,
57
- ELEVENLABS_OPTIMIZE_STREAMING_LATENCY :
58
- runtime . getSetting ( "ELEVENLABS_OPTIMIZE_STREAMING_LATENCY" ) ||
59
- process . env . ELEVENLABS_OPTIMIZE_STREAMING_LATENCY ,
60
- ELEVENLABS_OUTPUT_FORMAT :
61
- runtime . getSetting ( "ELEVENLABS_OUTPUT_FORMAT" ) ||
62
- process . env . ELEVENLABS_OUTPUT_FORMAT ,
37
+ ELEVENLABS_XI_API_KEY :
38
+ runtime . getSetting ( "ELEVENLABS_XI_API_KEY" ) ||
39
+ process . env . ELEVENLABS_XI_API_KEY ,
40
+
41
+ // Use character card settings first, fall back to env vars, then defaults
42
+ ...( runtime . getSetting ( "ELEVENLABS_XI_API_KEY" ) && {
43
+ ELEVENLABS_MODEL_ID :
44
+ elevenlabs ?. model ||
45
+ process . env . ELEVENLABS_MODEL_ID ||
46
+ "eleven_monolingual_v1" ,
47
+ ELEVENLABS_VOICE_ID :
48
+ elevenlabs ?. voiceId || process . env . ELEVENLABS_VOICE_ID ,
49
+ ELEVENLABS_VOICE_STABILITY :
50
+ elevenlabs ?. stability ||
51
+ process . env . ELEVENLABS_VOICE_STABILITY ||
52
+ "0.5" ,
53
+ ELEVENLABS_VOICE_SIMILARITY_BOOST :
54
+ elevenlabs ?. similarityBoost ||
55
+ process . env . ELEVENLABS_VOICE_SIMILARITY_BOOST ||
56
+ "0.75" ,
57
+ ELEVENLABS_VOICE_STYLE :
58
+ elevenlabs ?. style ||
59
+ process . env . ELEVENLABS_VOICE_STYLE ||
60
+ "0" ,
61
+ ELEVENLABS_VOICE_USE_SPEAKER_BOOST :
62
+ elevenlabs ?. useSpeakerBoost ||
63
+ process . env . ELEVENLABS_VOICE_USE_SPEAKER_BOOST ||
64
+ "true" ,
65
+ ELEVENLABS_OPTIMIZE_STREAMING_LATENCY :
66
+ process . env . ELEVENLABS_OPTIMIZE_STREAMING_LATENCY || "0" ,
67
+ ELEVENLABS_OUTPUT_FORMAT :
68
+ process . env . ELEVENLABS_OUTPUT_FORMAT || "pcm_16000" ,
69
+ } ) ,
70
+
71
+ // VITS settings
72
+ VITS_VOICE : voiceSettings ?. model || process . env . VITS_VOICE ,
73
+ VITS_MODEL : process . env . VITS_MODEL ,
63
74
} ;
64
75
65
76
return nodeEnvSchema . parse ( config ) ;
0 commit comments