Ho un problema nella mia app per Android, è un'app che utilizza il riconoscimento vocale e Google TTS. È come un client SIRI. Come si può vedere qui, quando l'utente dice una parola data nella matrice:L'array rileva solo una parte di una parola di input anziché l'intera parola
String[] g = { "hallo", "heey", "hoi", "hey", "he", "hee", "hay" };
for (String strings : g) {
if (mostLikelyThingHeard.contains(strings)) {
String[] array = { "leuk dat je er bent", "heeyy" };
String randomStr = array[new Random()
.nextInt(array.length)];
tts.speak(randomStr, TextToSpeech.QUEUE_FLUSH, null);
return;
}
}
String[] f = { "haha", "hah", "ha" };
for (String strings : f) {
if (mostLikelyThingHeard.contains(strings)) {
String[] array = { "haha leuk grapje", "hiehaho" };
String randomStr = array[new Random()
.nextInt(array.length)];
tts.speak(randomStr, TextToSpeech.QUEUE_FLUSH, null);
return;
}
}
Tutto sta funzionando bene, ma quando l'utente dice "hallo" rileva i primi due caratteri "ha" prime. Che è menzionato nell'array di stringhe 'f'. Quindi questo è fastidioso, l'intera parola non viene rilevata ma solo una parte da esso.
Quando ho scambiare i due array di stringhe come questo:
String[] f = { "haha", "hah", "ha" };
for (String strings : f) {
if (mostLikelyThingHeard.contains(strings)) {
String[] array = { "haha leuk grapje", "hiehaho" };
String randomStr = array[new Random()
.nextInt(array.length)];
tts.speak(randomStr, TextToSpeech.QUEUE_FLUSH, null);
return;
}
}
String[] g = { "hallo", "heey", "hoi", "hey", "he", "hee",
"hay" };
for (String strings : g) {
if (mostLikelyThingHeard.contains(strings)) {
String[] array = { "leuk dat je er bent", "heeyy" };
String randomStr = array[new Random()
.nextInt(array.length)];
tts.speak(randomStr, TextToSpeech.QUEUE_FLUSH, null);
return;
}
}
Poi si fa rilevare "hallo" prima invece di "ha"
Ma se io faccio più di 100 matrici questo sarebbe fastidioso , quindi, come posso consentire a java di utilizzare la parola di corrispondenza migliore di una matrice anziché solo una parte?
so che è difficile da capire, ma se voi ragazzi non lo capiscono vedere la mia fonte qui: http://github.com/gi097/PWS
EDIT:
Quando cambio
contains
a
equals
Ho risolto questo problema ma ora ho ottenuto una nuova o NE:
Se creo un array come:
"I am"
Quando l'utente dice: "Io sono Giovanni" abbiamo il problema che "io" non è rilevato più a causa di uguale ... .
EDIT2
può essere fissato Penso che con la scissione mostLikelythingHeard "sono Giovanni" a "I" "am" "Giovanni", ma come?
Non so se funzionerà, se avessi ad esempio 100 matrici, rileverà un'intera parola invece di una parte di caratteri? –
Sì, confronterà l'intera parola. Quindi se la tua stringa è stata accettata e tu hai avuto e hallo nel tuo array, troverà hallo e non ha. Provalo. – SMA
Okay proverò quando sono a casa: D –