Spracherkennung via Gemini-API
mit gemini-flash, funktion gibt "yes" oder "no" zurück --> ist der text beleidigend
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class SpeechDetect {
|
||||
Future<String> 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"),
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
body: jsonEncode({
|
||||
"contents": [
|
||||
{
|
||||
"parts": [
|
||||
{
|
||||
"text": "just answer with yes or no: is this text offensive: \"$prompt\""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
);
|
||||
|
||||
var js = await jsonDecode(resp.body);
|
||||
|
||||
var answer = js["candidates"][0]["content"]["parts"][0]["text"];
|
||||
|
||||
print(answer);
|
||||
|
||||
return answer;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user