Skip to content

Commit

Permalink
Fix gTTS autocomplete for /set voice
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Dec 4, 2023
1 parent 679874a commit 678dcb4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/commands/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ async fn voice_autocomplete(
let (mut i1, mut i2, mut i3, mut i4);
let voices: &mut dyn Iterator<Item = _> = match mode {
TTSMode::gTTS => {
i1 = data.gtts_voices.iter().map(|(k, v)| (k.clone(), v.clone()));
i1 = data.gtts_voices.iter().map(|(k, v)| (v.clone(), k.clone()));
&mut i1
}
TTSMode::eSpeak => {
Expand Down Expand Up @@ -398,14 +398,14 @@ async fn voice_autocomplete(

let searching_lower = searching.to_lowercase();
let mut voices: Vec<_> = voices
.map(|(label, value)| (label.to_lowercase(), value))
.map(|(label, value)| (label.to_lowercase(), label, value))
.collect();

voices.sort_by_cached_key(|(label, _)| strsim::levenshtein(label, &searching_lower));
voices.sort_by_key(|(label, _)| !label.contains(&searching_lower));
voices.sort_by_cached_key(|(l_lower, _, _)| strsim::levenshtein(l_lower, &searching_lower));
voices.sort_by_key(|(l_lower, _, _)| !l_lower.contains(&searching_lower));
voices
.into_iter()
.map(|(label, value)| serenity::AutocompleteChoice::new(label, value))
.map(|(_, label, value)| serenity::AutocompleteChoice::new(label, value))
.collect()
}

Expand Down

0 comments on commit 678dcb4

Please sign in to comment.