add speech2text options
This commit is contained in:
parent
4b739a04d9
commit
a4be2e8671
|
|
@ -53,7 +53,7 @@ public partial class ImageCompletionProvider
|
|||
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
var size = GetImageSize(state.GetState("image_size"));
|
||||
var format = GetImageFormat(state.GetState("image_format"));
|
||||
var format = GetImageFormat(state.GetState("image_response_format"));
|
||||
var count = GetImageCount(state.GetState("image_count", "1"));
|
||||
|
||||
var options = new ImageEditOptions
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public partial class ImageCompletionProvider
|
|||
var size = GetImageSize(state.GetState("image_size"));
|
||||
var quality = GetImageQuality(state.GetState("image_quality"));
|
||||
var style = GetImageStyle(state.GetState("image_style"));
|
||||
var format = GetImageFormat(state.GetState("image_format"));
|
||||
var format = GetImageFormat(state.GetState("image_response_format"));
|
||||
var count = GetImageCount(state.GetState("image_count", "1"));
|
||||
|
||||
var options = new ImageGenerationOptions
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public partial class ImageCompletionProvider
|
|||
{
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
var size = GetImageSize(state.GetState("image_size"));
|
||||
var format = GetImageFormat(state.GetState("image_format"));
|
||||
var format = GetImageFormat(state.GetState("image_response_format"));
|
||||
var count = GetImageCount(state.GetState("image_count", "1"));
|
||||
|
||||
var options = new ImageVariationOptions
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class EditImageFn : IFunctionCallback
|
|||
private void SetImageOptions()
|
||||
{
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
state.SetState("image_format", "bytes");
|
||||
state.SetState("image_response_format", "bytes");
|
||||
state.SetState("image_count", "1");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class GenerateImageFn : IFunctionCallback
|
|||
private void SetImageOptions()
|
||||
{
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
state.SetState("image_format", "bytes");
|
||||
state.SetState("image_response_format", "bytes");
|
||||
state.SetState("image_count", "1");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,37 +17,73 @@ public partial class AudioCompletionProvider
|
|||
private AudioTranscriptionOptions PrepareTranscriptionOptions(string? text)
|
||||
{
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
var format = GetTranscriptionResponseFormat(state.GetState("audio_response_format"));
|
||||
var granularity = GetGranularity(state.GetState("audio_granularity"));
|
||||
var temperature = GetTemperature(state.GetState("audio_temperature"));
|
||||
|
||||
var options = new AudioTranscriptionOptions
|
||||
{
|
||||
ResponseFormat = AudioTranscriptionFormat.Verbose,
|
||||
Granularities = AudioTimestampGranularities.Word | AudioTimestampGranularities.Segment,
|
||||
ResponseFormat = format,
|
||||
Granularities = granularity,
|
||||
Temperature = temperature,
|
||||
Prompt = text
|
||||
};
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
private AudioTranscriptionFormat GetTranscriptionResponseFormat(string format)
|
||||
private AudioTranscriptionFormat GetTranscriptionResponseFormat(string input)
|
||||
{
|
||||
var value = !string.IsNullOrEmpty(format) ? format : "verbose";
|
||||
var value = !string.IsNullOrEmpty(input) ? input : "verbose";
|
||||
|
||||
AudioTranscriptionFormat retFormat;
|
||||
AudioTranscriptionFormat format;
|
||||
switch (value)
|
||||
{
|
||||
case "json":
|
||||
retFormat = AudioTranscriptionFormat.Simple;
|
||||
format = AudioTranscriptionFormat.Simple;
|
||||
break;
|
||||
case "srt":
|
||||
retFormat = AudioTranscriptionFormat.Srt;
|
||||
format = AudioTranscriptionFormat.Srt;
|
||||
break;
|
||||
case "vtt":
|
||||
retFormat = AudioTranscriptionFormat.Vtt;
|
||||
format = AudioTranscriptionFormat.Vtt;
|
||||
break;
|
||||
default:
|
||||
retFormat = AudioTranscriptionFormat.Verbose;
|
||||
format = AudioTranscriptionFormat.Verbose;
|
||||
break;
|
||||
}
|
||||
|
||||
return retFormat;
|
||||
return format;
|
||||
}
|
||||
|
||||
private AudioTimestampGranularities GetGranularity(string input)
|
||||
{
|
||||
var value = !string.IsNullOrEmpty(input) ? input : "default";
|
||||
|
||||
AudioTimestampGranularities granularity;
|
||||
switch (value)
|
||||
{
|
||||
case "word":
|
||||
granularity = AudioTimestampGranularities.Word;
|
||||
break;
|
||||
case "segment":
|
||||
granularity = AudioTimestampGranularities.Segment;
|
||||
break;
|
||||
default:
|
||||
granularity = AudioTimestampGranularities.Default;
|
||||
break;
|
||||
}
|
||||
|
||||
return granularity;
|
||||
}
|
||||
|
||||
private float GetTemperature(string input)
|
||||
{
|
||||
if (!float.TryParse(input, out var temperature))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return temperature;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public partial class ImageCompletionProvider
|
|||
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
var size = GetImageSize(state.GetState("image_size"));
|
||||
var format = GetImageFormat(state.GetState("image_format"));
|
||||
var format = GetImageFormat(state.GetState("image_response_format"));
|
||||
var count = GetImageCount(state.GetState("image_count", "1"));
|
||||
|
||||
var options = new ImageEditOptions
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public partial class ImageCompletionProvider
|
|||
var size = GetImageSize(state.GetState("image_size"));
|
||||
var quality = GetImageQuality(state.GetState("image_quality"));
|
||||
var style = GetImageStyle(state.GetState("image_style"));
|
||||
var format = GetImageFormat(state.GetState("image_format"));
|
||||
var format = GetImageFormat(state.GetState("image_response_format"));
|
||||
var count = GetImageCount(state.GetState("image_count", "1"));
|
||||
|
||||
var options = new ImageGenerationOptions
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public partial class ImageCompletionProvider
|
|||
{
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
var size = GetImageSize(state.GetState("image_size"));
|
||||
var format = GetImageFormat(state.GetState("image_format"));
|
||||
var format = GetImageFormat(state.GetState("image_response_format"));
|
||||
var count = GetImageCount(state.GetState("image_count", "1"));
|
||||
|
||||
var options = new ImageVariationOptions
|
||||
|
|
|
|||
Loading…
Reference in a new issue