frimelle HF Staff commited on
Commit
b41502f
·
1 Parent(s): 794256c

refine the prompt, add random topic

Browse files
Files changed (1) hide show
  1. src/prompts.py +46 -26
src/prompts.py CHANGED
@@ -1,4 +1,4 @@
1
- # src/prompts.py
2
 
3
  def get_consent_generation_prompt(audio_model_name: str) -> str:
4
  """
@@ -7,33 +7,53 @@ def get_consent_generation_prompt(audio_model_name: str) -> str:
7
 
8
  Args:
9
  audio_model_name (str): Name of the audio model to mention in the prompt.
10
- short_prompt (bool): If True, returns a concise one-line prompt suitable
11
- for direct model input. If False (default), returns the full detailed prompt.
12
 
13
  Returns:
14
- str: The prompt text.
15
  """
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  return f"""
18
- Generate a short, natural-sounding English sentence (10–20 words) that a person could say aloud
19
- to clearly state their informed consent to use their voice for generating synthetic audio with
20
- an AI model called {audio_model_name}.
21
-
22
- The sentence should:
23
- - Sound natural and conversational, not like legal text.
24
- - Explicitly include a consent phrase, such as “I give my consent,” “I agree,” or “I allow.”
25
- - Mention the model name ({audio_model_name}) clearly in the sentence.
26
- - Include a neutral descriptive clause before or after the consent phrase to add phonetic variety
27
- (e.g., “The weather today is bright and calm” or “This recording is made clearly and freely.”)
28
- - Have a neutral or polite tone (no emotional extremes).
29
- - Be comfortable to read aloud and phonetically rich, covering diverse vowels and consonants naturally.
30
- - Be self-contained, so the full sentence can serve as an independent audio clip.
31
-
32
- Examples of structure to follow:
33
- - “The weather is clear and warm today. I give my consent to use my voice for generating audio with the model {audio_model_name}.”
34
- - “I give my consent to use my voice for generating audio with the model {audio_model_name}. This statement is made freely and clearly.”
35
- - “Good afternoon. I agree to the use of my recorded voice for audio generation with the model {audio_model_name}.”
36
-
37
- The output should be one to three natural sentences ready to be spoken aloud for recording purposes.
38
- Only output the sentences that the speaker should read, no extra information, no justifications, no formatting or lists. Only the suggested sentence.
39
- """
 
 
 
1
+ import random
2
 
3
  def get_consent_generation_prompt(audio_model_name: str) -> str:
4
  """
 
7
 
8
  Args:
9
  audio_model_name (str): Name of the audio model to mention in the prompt.
 
 
10
 
11
  Returns:
12
+ str: The prompt text, with a randomized topic for the second sentence.
13
  """
14
 
15
+ # Possible neutral or everyday topics to diversify phonetic variety
16
+ topics = [
17
+ "the weather",
18
+ "daily routines",
19
+ "travel or commuting",
20
+ "food or cooking",
21
+ "music",
22
+ "nature or seasons",
23
+ "time of day",
24
+ "a calm place like a park or café",
25
+ "light exercise or relaxation",
26
+ "reading or learning something new",
27
+ "a pleasant conversation with a friend",
28
+ "observing surroundings like streets or sky",
29
+ "working or focusing quietly"
30
+ ]
31
+
32
+ # Randomly choose one for this prompt instance
33
+ topic = random.choice(topics)
34
+
35
  return f"""
36
+ Generate exactly two short, natural-sounding English sentences (10-15 words each) that a person could say aloud, using everyday language.
37
+
38
+ Sentence 1 (Consent sentence):
39
+ * Clearly states informed consent to use their voice for generating synthetic audio with an AI model called {audio_model_name}.
40
+ * Must explicitly include a consent phrase such as “I give my consent,” “I agree,” or “I allow.”
41
+ * Must clearly mention the model name {audio_model_name} in the sentence.
42
+ * Should sound fluent, polite, and natural to read aloud.
43
+ * Should have a neutral or positive tone and be self-contained.
44
+
45
+ Sentence 2 (Phonetic variety sentence):
46
+ * Should not repeat the consent content.
47
+ * Adds phonetic variety with a neutral descriptive clause, for example about {topic}.
48
+ * Should be fluent, natural, and comfortable to read aloud.
49
+ * Should sound polite and neutral, without emotional extremes.
50
+ * Should include diverse vowels and consonants naturally for clear pronunciation.
51
+
52
+ FORMAT:
53
+ * Output EXACTLY two sentences.
54
+ * No numbering, no quotes, no bullet points, and no introductory text.
55
+ * Use standard punctuation.
56
+
57
+ Example format (don’t copy text, just the format):
58
+ I give my consent to use my voice for generating audio with the model {audio_model_name}. The weather is clear and calm this afternoon, and I’m speaking at an even pace.
59
+ """