how to make prefix null if radiobutton1 is unchecked and make it prefixaudio =…
- User
how to make prefix null if radiobutton1 is unchecked and make it prefix_audio = File.ReadAllBytes(MyLink.Text) if checked.
async Task TTS(string voiceId, string Text) { // Construct your request object including the new voice ID var request = new { model = "Zyphra/Zonos-v0.1-transformer", input = Text, language = "en-us", voice = voiceId, speed = float.Parse(SpeechSpeedBox.Text), emotion = new { happiness = float.Parse(HappyBox.Text), sadness = float.Parse(SadBox.Text), disgust = float.Parse(GrossBox.Text), fear = float.Parse(ScaredBox.Text), surprise = float.Parse(ShockedBox.Text), anger = float.Parse(AngryBox.Text), other = float.Parse(OtherBox.Text), neutral = float.Parse(NeutralBox.Text) }, response_format = "wav", vq_single = 1.0f, fmax = 24000.0f, pitch_std = 2f, speaking_rate = float.Parse(SpeechSpeedBox.Text), dnsmos_ovrl = 0.0f, speaker_noised = false, cfg_scale = 4, min_p = 0.15f, seed = GenerateRandomSeed(), randomize_seed = true, unconditional_keys = string.Empty, prefix_audio = File.ReadAllBytes(MyLink.Text) };
code// Serialize the request object into JSON var json = JsonConvert.SerializeObject(request); var content = new StringContent(json, Encoding.UTF8, "application/json"); try { // Send a POST request to the speech generation endpoint var response = await MyClient.PostAsync($"{baseUrl}/v1/audio/speech", content); response.EnsureSuccessStatusCode(); // Read the response content as a stream var audioStream = await response.Content.ReadAsStreamAsync(); // Specify the output path for the generated audio var outputFilePath = @"H:\Hot\Pookie\Poo\poo\api\zonos.git\app\audio.wav"; // Update this to .wav extension // Save the audio stream to a file using (var fileStream = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write)) { await audioStream.CopyToAsync(fileStream); } duration = GetWaveFileDuration(outputFilePath); audioFilePath = outputFilePath; PlayAudio(ISim, duration, false); } catch (HttpRequestException e) { MessageBox.Show("Error sending request to the speech generation server:\n" + e.Message); } catch (TaskCanceledException e) { MessageBox.Show("The request timed out:\n" + e.Message); } catch (Exception ex) { MessageBox.Show("An unexpected error occurred:\n" + ex.Message); } - Assistant