-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvoice_assist_draft.rs
37 lines (32 loc) · 1.3 KB
/
voice_assist_draft.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::process::Command;
use std::{thread, time};
use wikipedia::{Wikipedia, PageSummary};
use serde_json::Value;
use regex::Regex;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let mut engine = pyttsx3::init()?;
let voices = engine.property("voices")?;
engine.set_property("voice", &voices[1].id)?;
loop {
let query = take_command()?;
let query = query.trim().to_lowercase();
if query.contains("wikipedia") {
let search_term = query.replace("wikipedia", "").trim();
let result = get_wikipedia_summary(search_term)?;
speak(&format!("According to wikipedia, {}", result));
} else if query.contains("are you") {
speak("I am Amigo developed by Jaspreet Singh");
} else if query.contains("open youtube") {
open_website("https://www.youtube.com/");
} else if query.contains("open google") {
open_website("https://www.google.com/");
} else if query.contains("open github") {
open_website("https://github.com/");
} else if query.contains("open stackoverflow") {
open_website("https://stackoverflow.com/");
} else query.contains("open spotify") {
open_website("https://www.spotify.com/");
}
}
}draft