speech detect with gemini
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:mensaapp/modules/SpeechDetect.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -84,6 +85,20 @@ class DatabaseService {
|
||||
|
||||
Future<void> sendDataToSupabase(Map<String, dynamic> data) async {
|
||||
try {
|
||||
String llmPrompt = data["page1"]["t1"] + data["page2"]["t1"] + data["page3"]["t1"];
|
||||
|
||||
bool notNice = await SpeechDetect.prompt(llmPrompt);
|
||||
|
||||
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11");
|
||||
print(llmPrompt);
|
||||
print(notNice);
|
||||
|
||||
if (notNice) {
|
||||
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
print("not nice text cancel culturedXD");
|
||||
return;
|
||||
}
|
||||
|
||||
final response = await supabase.from('ratings_database').insert({"ratings": data});
|
||||
print("Antwort von Supabase: $response");
|
||||
|
||||
@@ -152,7 +167,7 @@ class DatabaseService {
|
||||
? null // Button deaktivieren
|
||||
: () async {
|
||||
Navigator.of(dialogContext).pop(); // Dialog schließen
|
||||
await sendDataToSupabase(data);
|
||||
sendDataToSupabase(data);
|
||||
Provider.of<EssenProvider>(context, listen: false).resetAllFields();
|
||||
Provider.of<ServiceProvider>(context, listen: false).resetAllFields();
|
||||
Provider.of<SpezielleErnaehrungProvider>(context, listen: false).resetAllFields();
|
||||
|
||||
Reference in New Issue
Block a user