Formatting
This commit is contained in:
1 parent
3f43676580
commit
878ff3f1e4
6 files changed
+36
-16
No files matched your search
@@ -86,8 +86,15 @@ pub fn delete_stats(stat: &[CardStatistics], connection: &Connection) {
|
||||
if stat.is_empty() {
|
||||
return;
|
||||
}
|
||||
let ids = stat.iter().map(|s| s.id.into()).collect::<Vec<String>>().join(", ");
|
||||
let ids = stat
|
||||
.iter()
|
||||
.map(|s| s.id.into())
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ");
|
||||
connection
|
||||
.execute(format!("DELETE FROM card_stats WHERE id in {ids}").as_str(), ())
|
||||
.execute(
|
||||
format!("DELETE FROM card_stats WHERE id in {ids}").as_str(),
|
||||
(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ pub async fn get_voice(text: &str) -> Result<BufReader<File>, ()> {
|
||||
let mut path = app_data_dir();
|
||||
path.push("voice");
|
||||
if !path.exists() {
|
||||
std::fs::create_dir(path.clone()).map_err(|_|())?;
|
||||
std::fs::create_dir(path.clone()).map_err(|_| ())?;
|
||||
}
|
||||
let hash = format!("{}.wav", hex::encode(Sha256::digest(text.as_bytes())));
|
||||
path.push(hash);
|
||||
@@ -20,19 +20,21 @@ pub async fn get_voice(text: &str) -> Result<BufReader<File>, ()> {
|
||||
.send()
|
||||
.await;
|
||||
|
||||
let query = query.map_err(|_|())?.text().await.map_err(|_|())?;
|
||||
let query = query.map_err(|_| ())?.text().await.map_err(|_| ())?;
|
||||
// Synthesis
|
||||
let audio = client
|
||||
.post(format!("{engine_url}/synthesis?speaker=11"))
|
||||
.header("Content-Type", "application/json")
|
||||
.body(query)
|
||||
.send()
|
||||
.await.map_err(|_|())?
|
||||
.await
|
||||
.map_err(|_| ())?
|
||||
.bytes()
|
||||
.await.map_err(|_|())?;
|
||||
.await
|
||||
.map_err(|_| ())?;
|
||||
|
||||
tokio::fs::write(&path, &audio).await.map_err(|_|())?;
|
||||
tokio::fs::write(&path, &audio).await.map_err(|_| ())?;
|
||||
}
|
||||
|
||||
Ok(BufReader::new(File::open(path).map_err(|_|())?))
|
||||
Ok(BufReader::new(File::open(path).map_err(|_| ())?))
|
||||
}
|
||||
Reference in new issue
Block a user