From 427d67b135e790716d8c117e635103f9aeccce79 Mon Sep 17 00:00:00 2001 From: panuozzo77 Date: Tue, 9 Jan 2024 21:19:41 +0100 Subject: [PATCH] added javadoc for SpeechRecognition --- .../service/exercise/SpeechRecognition.java | 6 +++- .../exercise/SpeechRecognitionInterface.java | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/main/java/model/service/exercise/SpeechRecognitionInterface.java diff --git a/src/main/java/model/service/exercise/SpeechRecognition.java b/src/main/java/model/service/exercise/SpeechRecognition.java index 0f5a677..f143d46 100644 --- a/src/main/java/model/service/exercise/SpeechRecognition.java +++ b/src/main/java/model/service/exercise/SpeechRecognition.java @@ -11,11 +11,15 @@ import java.util.concurrent.Future; -public class SpeechRecognition { +public class SpeechRecognition implements SpeechRecognitionInterface{ private static final String AZURE_PROPERTIES = "/azure.properties"; private static String speechKey; private static String speechRegion; + /** + * Costruttore della classe SpeechRecognition. + * Carica le chiavi e la regione di Azure Speech-to-Text dal file di configurazione. + */ public SpeechRecognition(){ Properties azureProps = loadProps(); speechRegion = azureProps.getProperty("azure.region"); diff --git a/src/main/java/model/service/exercise/SpeechRecognitionInterface.java b/src/main/java/model/service/exercise/SpeechRecognitionInterface.java new file mode 100644 index 0000000..a982643 --- /dev/null +++ b/src/main/java/model/service/exercise/SpeechRecognitionInterface.java @@ -0,0 +1,28 @@ +package model.service.exercise; + +import java.io.*; +import java.util.concurrent.ExecutionException; + + +public interface SpeechRecognitionInterface { + + /** + * Effettua il riconoscimento vocale utilizzando i servizi di Azure Speech-to-Text. + * + * @param audio InputStream rappresentante l'audio da analizzare. + * @return Una stringa contenente il testo riconosciuto, o null se non riconosciuto. + * @throws InterruptedException se il thread viene interrotto durante l'esecuzione. + * @throws ExecutionException se si verifica un errore durante l'esecuzione del task. + * @throws IOException se si verifica un errore di input/output. + */ + public String azureSTT(InputStream audio) throws InterruptedException, ExecutionException, IOException; + + /** + * Genera un file temporaneo a partire da un InputStream. + * + * @param inputAudio InputStream dell'audio. + * @return Il percorso del file temporaneo creato. + * @throws IOException se si verifica un errore di input/output. + */ + public String generateFile(InputStream inputAudio) throws IOException; +}