mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-05 08:55:54 +08:00
Translate learn page and add audio speed control
This commit is contained in:
@@ -64,6 +64,11 @@ function sanitizeConfig(input: Partial<LearnConfig> | undefined): LearnConfig |
|
||||
config.radioLevel = Math.min(5, Math.max(1, level))
|
||||
}
|
||||
|
||||
if (typeof input.audioSpeed === 'number' && Number.isFinite(input.audioSpeed)) {
|
||||
const rounded = Math.round(input.audioSpeed * 10) / 10
|
||||
config.audioSpeed = Math.min(1.3, Math.max(0.7, rounded))
|
||||
}
|
||||
|
||||
if (typeof input.voice === 'string') {
|
||||
config.voice = input.voice.slice(0, 120)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ const learnProfileSchema = new mongoose.Schema<LearnProfileDocument>(
|
||||
radioLevel: { type: Number, default: 4, min: 1, max: 5 },
|
||||
voice: { type: String, default: '', trim: true },
|
||||
audioChallenge: { type: Boolean, default: false },
|
||||
audioSpeed: { type: Number, default: 1, min: 0.5, max: 2 },
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ export interface LearnConfig {
|
||||
radioLevel: number
|
||||
voice: string
|
||||
audioChallenge: boolean
|
||||
audioSpeed: number
|
||||
}
|
||||
|
||||
export interface LearnState {
|
||||
@@ -23,6 +24,7 @@ export const LEARN_CONFIG_DEFAULTS: LearnConfig = {
|
||||
radioLevel: 4,
|
||||
voice: '',
|
||||
audioChallenge: false,
|
||||
audioSpeed: 1,
|
||||
}
|
||||
|
||||
export function createDefaultLearnConfig(): LearnConfig {
|
||||
|
||||
Reference in New Issue
Block a user