use Whisper in streaming mode
This commit is contained in:
@@ -64,18 +64,6 @@ public class InvokeAiClient : MonoBehaviour
|
||||
return JObject.Parse(json);
|
||||
}
|
||||
|
||||
private async Task<string> GetImageUrl(string imageName)
|
||||
{
|
||||
var requestUri = $"/api/v1/images/i/{Uri.EscapeDataString(imageName)}/urls";
|
||||
UnityEngine.Debug.Log("Get image URL: " + requestUri);
|
||||
using var resp = await httpClient.GetAsync(requestUri).ConfigureAwait(false);
|
||||
resp.EnsureSuccessStatusCode();
|
||||
|
||||
var json = await resp.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var root = JObject.Parse(json);
|
||||
return root.Value<string>("image_url");
|
||||
}
|
||||
|
||||
|
||||
private async Task<JObject> WaitForCompletion(string batchId, int timeoutSeconds = 300)
|
||||
{
|
||||
@@ -449,6 +437,17 @@ public class InvokeAiClient : MonoBehaviour
|
||||
return graph;
|
||||
}
|
||||
|
||||
private async Task<string> GetImageUrl(string imageName)
|
||||
{
|
||||
var requestUri = $"/api/v1/images/i/{Uri.EscapeDataString(imageName)}/urls";
|
||||
using var resp = await httpClient.GetAsync(requestUri).ConfigureAwait(false);
|
||||
resp.EnsureSuccessStatusCode();
|
||||
|
||||
var json = await resp.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var root = JObject.Parse(json);
|
||||
return root.Value<string>("image_url");
|
||||
}
|
||||
|
||||
|
||||
private async Task<string> GenerateImageUrl(JObject arguments)
|
||||
{
|
||||
@@ -510,9 +509,7 @@ public class InvokeAiClient : MonoBehaviour
|
||||
if (string.IsNullOrEmpty(imageName))
|
||||
continue;
|
||||
|
||||
// Resolve relative URL for the image (API-dependent)
|
||||
string imageRelativeUrl = await GetImageUrl(imageName);
|
||||
return imageRelativeUrl;
|
||||
return await GetImageUrl(imageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -530,8 +527,9 @@ public class InvokeAiClient : MonoBehaviour
|
||||
["model_key"] = MODEL_KEY,
|
||||
};
|
||||
|
||||
UnityEngine.Debug.Log("Starting image generation...");
|
||||
string imageUrl = await GenerateImageUrl(args);
|
||||
|
||||
UnityEngine.Debug.Log("Image URL ready: " + imageUrl);
|
||||
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, imageUrl);
|
||||
using var resp = await httpClient.SendAsync(req, HttpCompletionOption.ResponseHeadersRead);
|
||||
|
||||
Reference in New Issue
Block a user