Add function to get prompt to generate consent text (short and long version, long default)

#1
by frimelle HF Staff - opened
Files changed (1) hide show
  1. src/utils/prompts.py +47 -0
src/utils/prompts.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # src/utils/prompts.py
2
+
3
+ def get_consent_generation_prompt(audio_model_name: str, short_prompt: bool = False) -> str:
4
+ """
5
+ Returns a text prompt instructing the model to generate a natural-sounding
6
+ consent sentence for voice cloning with the specified model.
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
+ if short_prompt:
18
+ return (
19
+ f"Generate one natural, spoken-style English sentence (10–20 words) in which a person "
20
+ f"clearly gives informed consent to use their voice for generating synthetic audio "
21
+ f"with the model {audio_model_name}. The sentence should sound conversational, include "
22
+ f"a clear consent phrase like 'I give my consent' or 'I agree', mention {audio_model_name} "
23
+ f"by name, and be phonetically varied but neutral in tone. Output only the final sentence."
24
+ )
25
+
26
+ return f"""
27
+ Generate a short, natural-sounding English sentence (10–20 words) that a person could say aloud
28
+ to clearly state their informed consent to use their voice for generating synthetic audio with
29
+ an AI model called {audio_model_name}.
30
+
31
+ The sentence should:
32
+ - Sound natural and conversational, not like legal text.
33
+ - Explicitly include a consent phrase, such as β€œI give my consent,” β€œI agree,” or β€œI allow.”
34
+ - Mention the model name ({audio_model_name}) clearly in the sentence.
35
+ - Include a neutral descriptive clause before or after the consent phrase to add phonetic variety
36
+ (e.g., β€œThe weather today is bright and calm” or β€œThis recording is made clearly and freely.”)
37
+ - Have a neutral or polite tone (no emotional extremes).
38
+ - Be comfortable to read aloud and phonetically rich, covering diverse vowels and consonants naturally.
39
+ - Be self-contained, so the full sentence can serve as an independent audio clip.
40
+
41
+ Examples of structure to follow:
42
+ - β€œThe weather is clear and warm today. I give my consent to use my voice for generating audio with the model {audio_model_name}.”
43
+ - β€œI give my consent to use my voice for generating audio with the model {audio_model_name}. This statement is made freely and clearly.”
44
+ - β€œGood afternoon. I agree to the use of my recorded voice for audio generation with the model {audio_model_name}.”
45
+
46
+ The output should be a single, natural sentence ready to be spoken aloud for recording purposes.
47
+ """