Class AIDictationServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- org.apache.sling.api.servlets.SlingSafeMethodsServlet
-
- org.apache.sling.api.servlets.SlingAllMethodsServlet
-
- com.composum.ai.backend.slingbase.AIDictationServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class AIDictationServlet extends org.apache.sling.api.servlets.SlingAllMethodsServlet
Servlet providing a dictation service - returns a transcribed text from an audio file.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected org.osgi.framework.BundleContext
bundleContext
protected AIConfigurationService
configurationService
protected GPTDictationService
dictationService
static String
PARAMETER_AUDIO_STREAM
Parameter to transmit the audio stream to be transcribed.static String
PARAMETER_CONTENT_TYPE
Parameter to transmit the content type of the audio, e.g.static String
PARAMETER_LANGUAGE
Parameter to transmit the language code to use, e.g.static String
PARAMETER_PROMPT
Parameter to transmit an optional prompt to give the AI some context, e.g.
-
Constructor Summary
Constructors Constructor Description AIDictationServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate(org.osgi.framework.BundleContext bundleContext)
protected void
doGet(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)
Returns whether dictation is enabled for the content in the suffix: status code OK means it's available, otherwise 404.protected void
doPost(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)
Implements the transcription operation.protected String
getMandatoryParameter(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, String parameterName)
protected Integer
getOptionalInt(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, String parameterName)
-
Methods inherited from class org.apache.sling.api.servlets.SlingAllMethodsServlet
doDelete, doPut, getAllowedRequestMethods, isMethodValid, mayService
-
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet
doGeneric, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service
-
-
-
-
Field Detail
-
PARAMETER_AUDIO_STREAM
public static final String PARAMETER_AUDIO_STREAM
Parameter to transmit the audio stream to be transcribed.- See Also:
- Constant Field Values
-
PARAMETER_CONTENT_TYPE
public static final String PARAMETER_CONTENT_TYPE
Parameter to transmit the content type of the audio, e.g. "audio/mpeg" for mp3, "audio/wav" for wav.- See Also:
- Constant Field Values
-
PARAMETER_LANGUAGE
public static final String PARAMETER_LANGUAGE
Parameter to transmit the language code to use, e.g. "en" for English, or null for automatic detection.- See Also:
- Constant Field Values
-
PARAMETER_PROMPT
public static final String PARAMETER_PROMPT
Parameter to transmit an optional prompt to give the AI some context, e.g. previous sentences.- See Also:
- Constant Field Values
-
configurationService
protected AIConfigurationService configurationService
-
dictationService
protected GPTDictationService dictationService
-
bundleContext
protected org.osgi.framework.BundleContext bundleContext
-
-
Method Detail
-
activate
public void activate(org.osgi.framework.BundleContext bundleContext)
-
getOptionalInt
protected Integer getOptionalInt(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, String parameterName) throws IOException
- Throws:
IOException
-
getMandatoryParameter
protected String getMandatoryParameter(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, String parameterName) throws IOException
- Throws:
IOException
-
doGet
protected void doGet(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException
Returns whether dictation is enabled for the content in the suffix: status code OK means it's available, otherwise 404.- Overrides:
doGet
in classorg.apache.sling.api.servlets.SlingSafeMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
doPost
protected void doPost(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException
Implements the transcription operation. Input parameters are (as a multipart form):- file: the audio stream to transcribe
- contentType: the content type of the audio, e.g. "audio/mpeg" for mp3, "audio/wav" for wav
- language: the language code to use, e.g. "en" for English, or null / empty for automatic detection
- prompt: an optional prompt to give the AI some context, e.g. previous sentences
- Overrides:
doPost
in classorg.apache.sling.api.servlets.SlingAllMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
-