Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions README.md

This file was deleted.

17 changes: 17 additions & 0 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ edition = "2021"
actix-web="4"
reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_json = "1.0"
actix-cors = "0.6.4"
94 changes: 92 additions & 2 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use std::str::Chars;
use std::{backtrace, str::Chars, panic};

use actix_web::{get, web, App, HttpServer, Responder, HttpResponse};
use actix_web::http::header::{Accept, ACCEPT};
use actix_web::{get, post, web, App, HttpServer, Responder, HttpResponse};
// use actix_web::{actix, client};
use reqwest::Client;
use reqwest::header::{HeaderMap, CONTENT_TYPE};
use serde_json::Value;
use actix_cors::Cors;
use std::collections::HashMap;

type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
pub struct ReturnCheckBody {
Expand Down Expand Up @@ -67,6 +71,24 @@ fn check_body(body_data: Chars) -> ReturnCheckBody {
return_data
}

async fn test_voicevox() -> HttpResponse {
// let mut map = HashMap::new();
// map.insert("speaker", "1");
// map.insert("text", "aa");

let client = Client::new();
let url = "http://0.0.0.0:50021/audio_query?text=qqq&speaker=3";
let response = client
.post(url)
.header("Content-Type", "application/json")
// .json(&map)
.send()
.await;
// .expect("Failed to send request");
println!("{:?}",response);
println!("test_voicevox");
HttpResponse::Ok().content_type("application/json").body(r#"{"return":"ok"}"#)
}

#[get("/")]
async fn hello() -> impl Responder {
Expand Down Expand Up @@ -145,12 +167,80 @@ async fn qiita() -> HttpResponse {
.body(json_string)
}

#[post("/vv")]
async fn vv_test() -> HttpResponse {
println!("vv");
let client = Client::new();
let url = "http://localhost:50021/audio_query?text=qqq&speaker=3";
let response = match client
.post(url)
.header("Content-Type", "application/json")
.send()
.await
{
Ok(resp) => match resp.text().await {
Ok(body) => body,
Err(e) => format!("Failed to read response body: {:?}", e),
},
Err(e) => format!("Failed to send request: {:?}", e),
};

println!("Response: {:?}", response);

// HTTPレスポンスを返す
HttpResponse::Ok().content_type("application/json").body(format!(r#"{{"response": "{}"}}"#, response))
// println!("{:?}",response);
// println!("test_voicevox");
// HttpResponse::Ok().content_type("application/json").body(r#"{"return":"ok"}"#)
// test_voicevox().await;
// HttpResponse::Ok().content_type("application/json").body(r#"{"return":"ok"}"#)
}
#[post("/voice")]
async fn voice() -> HttpResponse {
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
// map.insert("accept", "audio/wav");
// map.insert("Content-Type", "application/json");
let client = Client::new();
let url = "http://localhost:50021/synthesis?speaker=3";
let response = match client
.post(url)
.headers(headers)
.send()
.await
{
Ok(resp) => match resp.text().await {
Ok(body) => body,
Err(e) => format!("Failed to read response body: {:?}", e),
},
Err(e) => format!("Failed to send request: {:?}", e),
};

println!("Response: {:?}", response);

// HTTPレスポンスを返す
HttpResponse::Ok().content_type("application/json").body(format!(r#"{{"response": "{}"}}"#, response))

}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
// panic::set_hook(Box::new(|panic_info| {
// let backtrace = backtrace::Backtrace::capture();
// eprintln!("Panic occurred: {:?}", panic_info);
// eprintln!("Backtrace: {:?}", backtrace);
// }));

HttpServer::new(|| {

let cors = Cors::permissive();

App::new()
.wrap(cors)
.service(hello)
.service(qiita)
.service(vv_test)
.service(voice)
.route("/hey", web::get().to(manual_hello))
})
.bind(("0.0.0.0", 8080))?
Expand Down
34 changes: 0 additions & 34 deletions compose.yml

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/.eslintrc.json

This file was deleted.

35 changes: 0 additions & 35 deletions frontend/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions frontend/Dockerfile

This file was deleted.

36 changes: 0 additions & 36 deletions frontend/README.md

This file was deleted.

Binary file removed frontend/app/favicon.ico
Binary file not shown.
27 changes: 0 additions & 27 deletions frontend/app/globals.css

This file was deleted.

22 changes: 0 additions & 22 deletions frontend/app/layout.tsx

This file was deleted.

Loading