I have a c# code where it seems its not releasing the file It gets locked or something…
- User
I have a c# code where it seems its not releasing the file It gets locked or something the output please fix it without breaking anything ty.
public async Task ConvertVocals(string selectedVoicePath, string singingVoiceFile, int qualityValue) { const string outputsDir = @"C:\AI\UVR5_UI\outputs"; const string finalOutputPath = @"C:\output\folder\NewVoice.wav";
code// Clear output directory foreach (var file in Directory.GetFiles(outputsDir)) { try { File.Delete(file); } catch (Exception ex) { MessageBox.Show($"Failed to delete file '{file}': {ex.Message}"); } } using var client = new HttpClient { Timeout = Timeout.InfiniteTimeSpan }; try { using var sourceStream = File.OpenRead(singingVoiceFile); using var referenceStream = File.OpenRead(selectedVoicePath); using var form = new MultipartFormDataContent{ { new StreamContent(sourceStream) { Headers = { ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = ""source_file"", FileName = ""source.wav"" } } }, "source_file", "source.wav" }, { new StreamContent(referenceStream) { Headers = { ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = ""reference_file"", FileName = ""reference.wav"" } } }, "reference_file", "reference.wav" }, { new StringContent(qualityValue.ToString()), "diffusion_steps" }, { new StringContent("1.0"), "length_adjust" }, { new StringContent("0.7"), "inference_cfg_rate" }, { new StringContent("true"), "auto_f0_adjust" }, { new StringContent("0"), "pitch_shift" } };
code - Assistant
- User
I keep getting the error in the command that runs after the conversion (which the file should be done and over with by then) the error is cannot access NewVoice.wav basically.
'the command that runs after the conversion' public void CombineWavs() { try { string inputFolder = @"C:\output\folder"; string outputFile = @"C:\output\folder\combined.wav";
codevar concatenator = new WavCombiner(); concatenator.ConcatenateWavFiles(inputFolder, outputFile); MessageBox.Show("WAV files successfully concatenated!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }}
- Assistant