Class GPTDictationServiceImpl
- java.lang.Object
-
- com.composum.ai.backend.base.service.chat.impl.GPTDictationServiceImpl
-
- All Implemented Interfaces:
GPTDictationService
public class GPTDictationServiceImpl extends Object implements GPTDictationService
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GPTDictationServiceImpl.GPTDictationServiceConfig
Configures whether it's enabled (default false), the model and the request counts, and the maximum request size.protected class
GPTDictationServiceImpl.LimitedInputStream
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_MAX_REQUEST_SIZE
protected static String
DEFAULT_MODEL
protected static int
DEFAULTVALUE_REQUESTS_PER_DAY
protected static int
DEFAULTVALUE_REQUESTS_PER_HOUR
protected static int
DEFAULTVALUE_REQUESTS_PER_MINUTE
protected boolean
enabled
protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient
httpClient
protected RateLimiter
limiter
protected long
maxRequestSize
protected String
model
protected GPTInternalOpenAIHelper
openAIHelper
static String
URL_OPENAI_TRANSCRIPTIONS
-
Constructor Summary
Constructors Constructor Description GPTDictationServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
activate(GPTDictationServiceImpl.GPTDictationServiceConfig config)
protected void
deactivate()
boolean
isAvailable(GPTConfiguration configuration)
Whether the service is enabled and properly configured.protected void
modified(GPTDictationServiceImpl.GPTDictationServiceConfig config)
String
transcribe(InputStream audioStream, String contentType, String language, GPTConfiguration configuration, String prompt)
Transcribes the input audio to text.
-
-
-
Field Detail
-
URL_OPENAI_TRANSCRIPTIONS
public static final String URL_OPENAI_TRANSCRIPTIONS
- See Also:
- Constant Field Values
-
DEFAULTVALUE_REQUESTS_PER_MINUTE
protected static final int DEFAULTVALUE_REQUESTS_PER_MINUTE
- See Also:
- Constant Field Values
-
DEFAULTVALUE_REQUESTS_PER_HOUR
protected static final int DEFAULTVALUE_REQUESTS_PER_HOUR
- See Also:
- Constant Field Values
-
DEFAULTVALUE_REQUESTS_PER_DAY
protected static final int DEFAULTVALUE_REQUESTS_PER_DAY
- See Also:
- Constant Field Values
-
DEFAULT_MODEL
protected static final String DEFAULT_MODEL
- See Also:
- Constant Field Values
-
DEFAULT_MAX_REQUEST_SIZE
protected static final int DEFAULT_MAX_REQUEST_SIZE
- See Also:
- Constant Field Values
-
httpClient
protected org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient
-
limiter
protected RateLimiter limiter
-
enabled
protected boolean enabled
-
model
protected String model
-
maxRequestSize
protected long maxRequestSize
-
openAIHelper
protected GPTInternalOpenAIHelper openAIHelper
-
-
Method Detail
-
activate
protected void activate(GPTDictationServiceImpl.GPTDictationServiceConfig config) throws URISyntaxException
- Throws:
URISyntaxException
-
deactivate
protected void deactivate() throws IOException
- Throws:
IOException
-
modified
protected void modified(GPTDictationServiceImpl.GPTDictationServiceConfig config) throws IOException, URISyntaxException
- Throws:
IOException
URISyntaxException
-
isAvailable
public boolean isAvailable(@Nullable GPTConfiguration configuration)
Description copied from interface:GPTDictationService
Whether the service is enabled and properly configured.- Specified by:
isAvailable
in interfaceGPTDictationService
-
transcribe
public String transcribe(@Nonnull InputStream audioStream, @Nonnull String contentType, @Nullable String language, @Nullable GPTConfiguration configuration, @Nullable String prompt)
Description copied from interface:GPTDictationService
Transcribes the input audio to text.- Specified by:
transcribe
in interfaceGPTDictationService
- Parameters:
audioStream
- the audio stream to transcribe, will be closedcontentType
- the content type of the audio, e.g. "audio/mpeg" for mp3, "audio/wav" for wavlanguage
- the language code to use, e.g. "en" for English, or null for automatic detectionconfiguration
- the configuration to use, or null for the default configurationprompt
- an optional prompt to give the AI some context, e.g. previous sentences
-
-