speech detect with gemini

This commit is contained in:
Jonas Braus
2025-01-29 20:29:10 +01:00
parent bbb9f8ef51
commit 29ca4ba1ee
3 changed files with 33 additions and 20 deletions
+2 -4
View File
@@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
class SpeechDetect {
Future<String> prompt(String prompt) async {
static Future<bool> prompt(String prompt) async {
http.Response resp = await http.post(
Uri.parse(
"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=AIzaSyC9f3vPVuWAajpZEos35F8F5LaxcpcdlO4"),
@@ -27,8 +27,6 @@ class SpeechDetect {
var answer = js["candidates"][0]["content"]["parts"][0]["text"];
print(answer);
return answer;
return answer.toString().toLowerCase().contains("yes") ? true : false;
}
}