Skip to content

Commit 027fd11

Browse files
authored
Merge pull request transformerlab#777 from transformerlab/add/top-audio
Add Top P field for audio
2 parents 0da5883 + d39dffe commit 027fd11

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/renderer/components/Experiment/Audio/Audio.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export async function sendAndReceiveAudioPath(
3838
sample_rate: number,
3939
temperature: number,
4040
speed: number,
41+
topP: number,
4142
voice?: string,
4243
audioPath?: string,
4344
) {
@@ -50,6 +51,7 @@ export async function sendAndReceiveAudioPath(
5051
sample_rate: sample_rate,
5152
temperature: temperature,
5253
speed: speed,
54+
top_p: topP,
5355
};
5456

5557
if (voice) {
@@ -170,6 +172,7 @@ export default function Audio() {
170172
const [filePrefix, setFilePrefix] = React.useState('output_audio');
171173
const [sampleRate, setSampleRate] = React.useState(24000);
172174
const [temperature, setTemperature] = React.useState(0.7);
175+
const [topP, setTopP] = React.useState(1.0);
173176
const [selectedLanguage, setSelectedLanguage] = React.useState('');
174177
const [selectedVoice, setSelectedVoice] = React.useState('');
175178

@@ -200,6 +203,7 @@ export default function Audio() {
200203
sampleRate,
201204
temperature,
202205
speed,
206+
topP,
203207
selectedVoice || undefined,
204208
uploadedAudioPath || undefined,
205209
);
@@ -371,6 +375,21 @@ export default function Audio() {
371375
/>
372376
</FormControl>
373377

378+
<FormControl>
379+
<FormLabel>
380+
Top P: <b>{topP.toFixed(2)}</b>
381+
</FormLabel>
382+
<Slider
383+
aria-label="Top P"
384+
value={topP}
385+
onChange={(_, v) => setTopP(v as number)}
386+
min={0.0}
387+
max={1.0}
388+
step={0.01}
389+
valueLabelDisplay="auto"
390+
/>
391+
</FormControl>
392+
374393
<FormControl>
375394
<FormLabel>
376395
Speech Speed: <b>{speed}x</b>

src/renderer/components/Experiment/Audio/AudioHistory.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface AudioHistoryItem {
2323
audio_format: string;
2424
sample_rate: number;
2525
temperature: number;
26+
top_p?: number;
2627
voice?: string;
2728
audio_data_url?: string; // Add audio data URL for the AudioPlayer
2829
}
@@ -121,6 +122,9 @@ const AudioHistory = React.forwardRef<HTMLDivElement, AudioHistoryProps>(
121122
<Chip size="sm" variant="soft" color="neutral">
122123
Temp: {item.temperature}
123124
</Chip>
125+
<Chip size="sm" variant="soft" color="neutral">
126+
Top P: {item.top_p ? item.top_p : 'N/A'}
127+
</Chip>
124128
<Box sx={{ flex: 1 }} />
125129
<IconButton
126130
size="sm"

0 commit comments

Comments
 (0)