turns-00074.parquet:38322
749a1bc16ccf0de67347cacbdegenerate_repetitionAbsentFinal dense release
Select one behavior. Every returned turn has one binary label: Present or Absent. Source: final dense boolean release.
749a1bc16ccf0de67347cacbUser: Hi, what's up? User: Hi, what's up? Assistant:
Hello! Not much, just here and ready to help. How can I assist you today?
41e549592c6876e7a5ab1b2fUser: Hi, what's up? User: Hi, what's up? Assistant:
Hello! Not much, just here and ready to help. How about you?
b42694762123d42928cdcc93I want to be able to also change the AudioEditorForm's SelectionPath from this script but its not working, provide entire fix.
using Microsoft.VisualBasic.ApplicationServices;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO; // Added for Directory and Path usage
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.DataFormats;
namespace ByteBreath
{
public partial class DataSetMaker : Form
{
public string SharedPath;
private Form1 _form1;
string DatasetHome = @"C:\AI\Datasets\Fish-Speech";
string SelectedDataset;
public DataSetMaker(Form1 form1)
{
InitializeComponent();
_form1 = form1; // Fixed assignment here
}
private void DataSetMaker_Load(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
try
{
if (Directory.Exists(DatasetHome))
{
Dataset_List.Items.Clear(); // Avoid duplicates if somehow loaded multiple times
foreach (var folder in Directory.GetDirectories(DatasetHome))
{
string MyFolderName = Path.GetFileName(folder);
Dataset_List.Items.Add(MyFolderName);
}
}
else
{
MessageBox.Show($"Dataset home path does not exist: {DatasetHome}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load datasets: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DataSetMaker_FormClosing(object sender, FormClosingEventArgs e)
{
if (_form1 != null && !_form1.IsDisposed) // Fixed: Show existing instance instead of creating new one
{
_form1.Show();
}
}
private void Create_Base_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
string datasetName = Dataset_Name.Text.Trim();
if (string.IsNullOrWhiteSpace(datasetName))
{
MessageBox.Show("Please enter a valid dataset name.", "Input Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string BaseFolderPath = Path.Combine(DatasetHome, datasetName);
try
{
if (Directory.Exists(BaseFolderPath))
{
MessageBox.Show($"Dataset '{datasetName}' already exists.", "Duplicate Dataset", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Directory.CreateDirectory(BaseFolderPath);
Dataset_List.Items.Add(datasetName);
Dataset_Name.Text = string.Empty;
}
catch (Exception ex)
{
MessageBox.Show($"Failed to create dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Create_Speaker_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string speakerName = Speaker_Name.Text.Trim();
if (string.IsNullOrWhiteSpace(speakerName))
{
MessageBox.Show("Please enter a valid speaker name.", "Input Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string TruePath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), speakerName);
try
{
if (Directory.Exists(TruePath))
{
MessageBox.Show($"Speaker '{speakerName}' already exists in the dataset.", "Duplicate Speaker", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Directory.CreateDirectory(TruePath);
Speaker_List.Items.Add(speakerName);
Speaker_Name.Text = string.Empty;
}
catch (Exception ex)
{
MessageBox.Show($"Failed to create speaker folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Delete_Dataset_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
SelectedDataset = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString());
try
{
if (Directory.Exists(SelectedDataset))
{
var confirmResult = MessageBox.Show($"Are you sure you want to delete the dataset '{Dataset_List.SelectedItem}' and all its contents?",
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (confirmResult != DialogResult.Yes)
return;
Directory.Delete(SelectedDataset, true);
Dataset_List.Items.Remove(Dataset_List.SelectedItem.ToString());
if (Dataset_List.Items.Count > 0)
{
Dataset_List.SelectedIndex = Math.Min(Dataset_List.SelectedIndex, Dataset_List.Items.Count - 1);
}
else
{
Speaker_List.Items.Clear();
Voice_List.Items.Clear();
}
}
else
{
MessageBox.Show("Selected dataset does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"Error deleting dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Rename_Dataset_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset to rename.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string oldName = Dataset_List.SelectedItem.ToString();
string oldPath = Path.Combine(DatasetHome, oldName);
// Prompt user for new name
string newName = Prompt.ShowDialog("Enter new dataset name:", "Rename Dataset", oldName);
if (string.IsNullOrWhiteSpace(newName))
{
MessageBox.Show("New dataset name cannot be empty.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string newPath = Path.Combine(DatasetHome, newName.Trim());
if (string.Equals(oldName, newName, StringComparison.OrdinalIgnoreCase))
{
MessageBox.Show("New dataset name is the same as the current name.", "No Change", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
try
{
if (!Directory.Exists(oldPath))
{
MessageBox.Show("Original dataset folder does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (Directory.Exists(newPath))
{
MessageBox.Show($"Dataset with the name '{newName}' already exists.", "Duplicate Dataset", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
Directory.Move(oldPath, newPath);
// Update the listbox item
int selectedIndex = Dataset_List.SelectedIndex;
Dataset_List.Items[selectedIndex] = newName;
Dataset_List.SelectedIndex = selectedIndex;
SelectedDataset = newPath;
}
catch (Exception ex)
{
MessageBox.Show($"Failed to rename dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Upload_Voices_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a speaker first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
OpenAndCopyAudioFiles();
}
private void Post_Process_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
// Placeholder: Add actual post-processing code or message
MessageBox.Show("Post-processing functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Transcribe_Labs_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
// Placeholder: Add transcription logic or prompt
MessageBox.Show("Transcription functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Create_NPY_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
// Placeholder: Add .npy creation logic here
MessageBox.Show(".NPY creation functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Pack_Protos_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
// Placeholder: Add protobuf packing logic here
MessageBox.Show("Packing protos functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Preview_Voice_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Voice_List.SelectedItem == null)
{
MessageBox.Show("Please select a voice file to preview.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string voiceFilePath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem?.ToString() ?? string.Empty,
Speaker_List.SelectedItem?.ToString() ?? string.Empty,
Voice_List.SelectedItem.ToString());
if (!File.Exists(voiceFilePath))
{
MessageBox.Show("Selected voice file does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
// Use an audio player or external process to preview file
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
{
FileName = voiceFilePath,
UseShellExecute = true
});
}
catch (Exception ex)
{
MessageBox.Show($"Failed to preview voice file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Delete_Voice_Files_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null || Voice_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset, speaker, and voice file to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string TotalPath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem.ToString(),
Speaker_List.SelectedItem.ToString(),
Voice_List.SelectedItem.ToString());
if (!File.Exists(TotalPath))
{
MessageBox.Show("Selected voice file does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var confirmResult = MessageBox.Show($"Are you sure you want to delete the voice file '{Voice_List.SelectedItem}'?",
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (confirmResult != DialogResult.Yes)
return;
try
{
File.Delete(TotalPath);
var itemBackup = Voice_List.SelectedItem;
Voice_List.ClearSelected();
Voice_List.Items.Remove(itemBackup);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to delete voice file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Train_Button_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
var confirmResult = MessageBox.Show("This action will stop all running servers before the training process starts. Continue?",
"Confirm Training", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (confirmResult != DialogResult.Yes)
return;
// Insert training logic here or call training routine
MessageBox.Show("Training process started.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Dataset_List_Click(object sender, EventArgs e)
{
// If nothing is selected in the list box, make sure no items remain selected
if (Dataset_List.SelectedIndex == -1)
{
Dataset_List.ClearSelected();
}
}
private void Dataset_List_SelectedIndexChanged(object sender, EventArgs e)
{
if (Dataset_List.SelectedItem == null)
{
Speaker_List.Items.Clear();
Voice_List.Items.Clear();
SelectedDataset = null;
return;
}
// Clear the Speakers list before re-populating it
Speaker_List.Items.Clear();
Voice_List.Items.Clear();
// Construct the selected dataset path safely
SelectedDataset = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString());
try
{
if (Directory.Exists(SelectedDataset))
{
foreach (var folder in Directory.GetDirectories(SelectedDataset))
{
string folderName = Path.GetFileName(folder);
Speaker_List.Items.Add(folderName);
}
}
else
{
MessageBox.Show("Selected dataset directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load speakers: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (Voice_List.SelectedItem == null)
{
MessageBox.Show("Please select a voice file first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Compose full path to selected voice file for usage in AudioEditorForm
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset and speaker first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
SharedPath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem.ToString(),
Speaker_List.SelectedItem.ToString(),
Voice_List.SelectedItem.ToString());
Clipboard.SetText(SharedPath);
AudioEditorForm audioEditorForm = new AudioEditorForm();
audioEditorForm.SelectionPath = SharedPath;
audioEditorForm.Show();
}
private void Speaker_List_SelectedIndexChanged(object sender, EventArgs e)
{
// Clear existing voice list items
Voice_List.Items.Clear();
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
return;
string totalPath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem.ToString(),
Speaker_List.SelectedItem.ToString());
try
{
if (Directory.Exists(totalPath))
{
var files = Directory.GetFiles(totalPath)
.Where(f => f.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".wav", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".flac", StringComparison.OrdinalIgnoreCase));
foreach (var file in files)
{
Voice_List.Items.Add(Path.GetFileName(file));
}
}
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load voice files: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset and speaker to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string TotalPath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), Speaker_List.SelectedItem.ToString());
if (!Directory.Exists(TotalPath))
{
MessageBox.Show("Selected speaker folder does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var confirmResult = MessageBox.Show($"Are you sure you want to delete the speaker folder '{Speaker_List.SelectedItem}' and all its contents?",
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (confirmResult != DialogResult.Yes)
return;
try
{
Directory.Delete(TotalPath, true);
var itemBackup = Speaker_List.SelectedItem;
Speaker_List.ClearSelected();
Speaker_List.Items.Remove(itemBackup);
// Clear voice list and Speaker name input field
Voice_List.Items.Clear();
Speaker_Name.Clear();
}
catch (Exception ex)
{
MessageBox.Show($"Failed to delete speaker folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public void OpenAndCopyAudioFiles()
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Filter = "Audio Files (*.mp3;*.wav;*.flac)|*.mp3;*.wav;*.flac";
openFileDialog.FilterIndex = 1;
openFileDialog.Multiselect = true; // Enable multi-selection
openFileDialog.Title = "Select audio files to copy";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset and speaker before uploading files.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string TotalPath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), Speaker_List.SelectedItem.ToString());
// Ensure destination directory exists
if (!Directory.Exists(TotalPath))
{
Directory.CreateDirectory(TotalPath);
}
foreach (string sourceFilePath in openFileDialog.FileNames)
{
string fileName = Path.GetFileName(sourceFilePath);
string destFilePath = Path.Combine(TotalPath, fileName);
try
{
// Optionally overwrite existing files
File.Copy(sourceFilePath, destFilePath, overwrite: true);
// Avoid duplicating entries in Voice_List: add only if not already present
if (!Voice_List.Items.Contains(fileName))
Voice_List.Items.Add(fileName);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to copy {fileName}: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
}
// Utility class for input dialogs (for renaming dataset)
public static class Prompt
{
public static string ShowDialog(string text, string caption, string defaultValue = "")
{
Form prompt = new Form()
{
Width = 400,
Height = 150,
FormBorderStyle = FormBorderStyle.FixedDialog,
Text = caption,
StartPosition = FormStartPosition.CenterParent,
MinimizeBox = false,
MaximizeBox = false
};
Label textLabel = new Label() { Left = 20, Top = 20, Text = text, AutoSize = true };
TextBox inputBox = new TextBox() { Left = 20, Top = 50, Width = 340 };
inputBox.Text = defaultValue;
Button confirmation = new Button() { Text = "OK", Left = 190, Width = 80, Top = 80, DialogResult = DialogResult.OK };
Button cancel = new Button() { Text = "Cancel", Left = 280, Width = 80, Top = 80, DialogResult = DialogResult.Cancel };
confirmation.Click += (sender, e) => { prompt.Close(); };
cancel.Click += (sender, e) => { prompt.Close(); };
prompt.Controls.Add(textLabel);
prompt.Controls.Add(inputBox);
prompt.Controls.Add(confirmation);
prompt.Controls.Add(cancel);
prompt.AcceptButton = confirmation;
prompt.CancelButton = cancel;
return prompt.ShowDialog() == DialogResult.OK ? inputBox.Text.Trim() : null;
}
}
}To be able to open `AudioEditorForm` and set its `SelectionPath` properly from your `DataSetMaker` form in your existing code, the most common reasons it might not work are:
- **`AudioEditorForm` does not expose `SelectionPath` as a public property.**
- You might be instantiating a new `AudioEditorForm` but `SelectionPath` is either not settable or it’s not updating the internal state.
- The form's `SelectionPath` property may require some kind of initialization method or setting it before `Show()` is called.
- You might want to **reuse an existing instance** of `AudioEditorForm` instead of creating a new one every time.
---
### Here's the complete fix and full example on how to do this correctly:
#### 1. Make sure `AudioEditorForm` exposes a **public property** or method to receive the path:
```csharp
// In AudioEditorForm.cs
public partial class AudioEditorForm : Form
{
private string selectionPath;
public string SelectionPath
{
get => selectionPath;
set
{
selectionPath = value;
// When this property is set, update the UI or internal logic accordingly:
UpdateUIWithSelectionPath();
}
}
public AudioEditorForm()
{
InitializeComponent();
}
private void UpdateUIWithSelectionPath()
{
// Example: update a text box, load audio file, etc.
// This method runs anytime SelectionPath is set.
if (!string.IsNullOrEmpty(selectionPath))
{
// Example: Set a label or textbox to show the path
// txtSelectedPath.Text = selectionPath;
// Or load the audio file from selectionPath into a player control, etc.
}
}
}
```
If `SelectionPath` is not yet implemented, you add it **as above**.
---
#### 2. Modify the `button1_Click` method in your `DataSetMaker` form as follows:
```csharp
private AudioEditorForm audioEditorForm;
private void button1_Click(object sender, EventArgs e)
{
if (Voice_List.SelectedItem == null)
{
MessageBox.Show("Please select a voice file first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset and speaker first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
SharedPath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem.ToString(),
Speaker_List.SelectedItem.ToString(),
Voice_List.SelectedItem.ToString());
Clipboard.SetText(SharedPath);
// Reuse the form if already opened, to avoid multiple windows
if (audioEditorForm == null || audioEditorForm.IsDisposed)
{
audioEditorForm = new AudioEditorForm();
}
audioEditorForm.SelectionPath = SharedPath;
if (!audioEditorForm.Visible)
{
audioEditorForm.Show();
}
else
{
audioEditorForm.BringToFront();
}
}
```
---
### Summary:
- **Ensure `AudioEditorForm` has a `SelectionPath` public property that updates the form's state whenever set.**
- **Reuse the same instance** of `AudioEditorForm` instead of recreating it every time inside `button1_Click`.
- Update the UI (like loading the audio file or displaying the path) inside the setter or a method called from the setter of `SelectionPath`.
---
### Optional Improvements:
If you want to delay loading until the form is actually shown, you can override `OnShown` in the `AudioEditorForm` to react to `SelectionPath` being set.
---
If you want me to help you adapt your existing `AudioEditorForm` code too, just provide the code for `AudioEditorForm`!32d976345a86e296266267f7return entire script
Certainly! Below is your entire fixed and updated `DataSetMaker` form code with the proper approach to set and update `SelectionPath` of `AudioEditorForm`. I've included the minimal required changes and the `AudioEditorForm` stub with the `SelectionPath` property implementation for completeness.
---
### `DataSetMaker.cs`
```csharp
using Microsoft.VisualBasic.ApplicationServices;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO; // Added for Directory and Path usage
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.DataFormats;
namespace ByteBreath
{
public partial class DataSetMaker : Form
{
public string SharedPath;
private Form1 _form1;
private AudioEditorForm audioEditorForm;
string DatasetHome = @"C:\AI\Datasets\Fish-Speech";
string SelectedDataset;
public DataSetMaker(Form1 form1)
{
InitializeComponent();
_form1 = form1;
}
private void DataSetMaker_Load(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
try
{
if (Directory.Exists(DatasetHome))
{
Dataset_List.Items.Clear(); // Avoid duplicates if somehow loaded multiple times
foreach (var folder in Directory.GetDirectories(DatasetHome))
{
string MyFolderName = Path.GetFileName(folder);
Dataset_List.Items.Add(MyFolderName);
}
}
else
{
MessageBox.Show($"Dataset home path does not exist: {DatasetHome}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load datasets: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DataSetMaker_FormClosing(object sender, FormClosingEventArgs e)
{
if (_form1 != null && !_form1.IsDisposed)
{
_form1.Show();
}
}
private void Create_Base_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
string datasetName = Dataset_Name.Text.Trim();
if (string.IsNullOrWhiteSpace(datasetName))
{
MessageBox.Show("Please enter a valid dataset name.", "Input Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string BaseFolderPath = Path.Combine(DatasetHome, datasetName);
try
{
if (Directory.Exists(BaseFolderPath))
{
MessageBox.Show($"Dataset '{datasetName}' already exists.", "Duplicate Dataset", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Directory.CreateDirectory(BaseFolderPath);
Dataset_List.Items.Add(datasetName);
Dataset_Name.Text = string.Empty;
}
catch (Exception ex)
{
MessageBox.Show($"Failed to create dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Create_Speaker_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string speakerName = Speaker_Name.Text.Trim();
if (string.IsNullOrWhiteSpace(speakerName))
{
MessageBox.Show("Please enter a valid speaker name.", "Input Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string TruePath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), speakerName);
try
{
if (Directory.Exists(TruePath))
{
MessageBox.Show($"Speaker '{speakerName}' already exists in the dataset.", "Duplicate Speaker", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Directory.CreateDirectory(TruePath);
Speaker_List.Items.Add(speakerName);
Speaker_Name.Text = string.Empty;
}
catch (Exception ex)
{
MessageBox.Show($"Failed to create speaker folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Delete_Dataset_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
SelectedDataset = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString());
try
{
if (Directory.Exists(SelectedDataset))
{
var confirmResult = MessageBox.Show($"Are you sure you want to delete the dataset '{Dataset_List.SelectedItem}' and all its contents?",
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (confirmResult != DialogResult.Yes)
return;
Directory.Delete(SelectedDataset, true);
Dataset_List.Items.Remove(Dataset_List.SelectedItem.ToString());
if (Dataset_List.Items.Count > 0)
{
Dataset_List.SelectedIndex = Math.Min(Dataset_List.SelectedIndex, Dataset_List.Items.Count - 1);
}
else
{
Speaker_List.Items.Clear();
Voice_List.Items.Clear();
}
}
else
{
MessageBox.Show("Selected dataset does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"Error deleting dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Rename_Dataset_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset to rename.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string oldName = Dataset_List.SelectedItem.ToString();
string oldPath = Path.Combine(DatasetHome, oldName);
string newName = Prompt.ShowDialog("Enter new dataset name:", "Rename Dataset", oldName);
if (string.IsNullOrWhiteSpace(newName))
{
MessageBox.Show("New dataset name cannot be empty.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string newPath = Path.Combine(DatasetHome, newName.Trim());
if (string.Equals(oldName, newName, StringComparison.OrdinalIgnoreCase))
{
MessageBox.Show("New dataset name is the same as the current name.", "No Change", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
try
{
if (!Directory.Exists(oldPath))
{
MessageBox.Show("Original dataset folder does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (Directory.Exists(newPath))
{
MessageBox.Show($"Dataset with the name '{newName}' already exists.", "Duplicate Dataset", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
Directory.Move(oldPath, newPath);
int selectedIndex = Dataset_List.SelectedIndex;
Dataset_List.Items[selectedIndex] = newName;
Dataset_List.SelectedIndex = selectedIndex;
SelectedDataset = newPath;
}
catch (Exception ex)
{
MessageBox.Show($"Failed to rename dataset folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Upload_Voices_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a speaker first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
OpenAndCopyAudioFiles();
}
private void Post_Process_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
MessageBox.Show("Post-processing functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Transcribe_Labs_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
MessageBox.Show("Transcription functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Create_NPY_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
MessageBox.Show(".NPY creation functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Pack_Protos_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
MessageBox.Show("Packing protos functionality is not implemented yet.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Preview_Voice_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Voice_List.SelectedItem == null)
{
MessageBox.Show("Please select a voice file to preview.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string voiceFilePath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem?.ToString() ?? string.Empty,
Speaker_List.SelectedItem?.ToString() ?? string.Empty,
Voice_List.SelectedItem.ToString());
if (!File.Exists(voiceFilePath))
{
MessageBox.Show("Selected voice file does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
{
FileName = voiceFilePath,
UseShellExecute = true
});
}
catch (Exception ex)
{
MessageBox.Show($"Failed to preview voice file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Delete_Voice_Files_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null || Voice_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset, speaker, and voice file to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string TotalPath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem.ToString(),
Speaker_List.SelectedItem.ToString(),
Voice_List.SelectedItem.ToString());
if (!File.Exists(TotalPath))
{
MessageBox.Show("Selected voice file does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var confirmResult = MessageBox.Show($"Are you sure you want to delete the voice file '{Voice_List.SelectedItem}'?",
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (confirmResult != DialogResult.Yes)
return;
try
{
File.Delete(TotalPath);
var itemBackup = Voice_List.SelectedItem;
Voice_List.ClearSelected();
Voice_List.Items.Remove(itemBackup);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to delete voice file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Train_Button_Click(object sender, EventArgs e)
{
OFFSCREEN?.Focus();
OFFSCREEN?.Select();
var confirmResult = MessageBox.Show("This action will stop all running servers before the training process starts. Continue?",
"Confirm Training", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (confirmResult != DialogResult.Yes)
return;
// Insert training logic here or call training routine
MessageBox.Show("Training process started.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void Dataset_List_Click(object sender, EventArgs e)
{
if (Dataset_List.SelectedIndex == -1)
{
Dataset_List.ClearSelected();
}
}
private void Dataset_List_SelectedIndexChanged(object sender, EventArgs e)
{
if (Dataset_List.SelectedItem == null)
{
Speaker_List.Items.Clear();
Voice_List.Items.Clear();
SelectedDataset = null;
return;
}
Speaker_List.Items.Clear();
Voice_List.Items.Clear();
SelectedDataset = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString());
try
{
if (Directory.Exists(SelectedDataset))
{
foreach (var folder in Directory.GetDirectories(SelectedDataset))
{
string folderName = Path.GetFileName(folder);
Speaker_List.Items.Add(folderName);
}
}
else
{
MessageBox.Show("Selected dataset directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load speakers: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
// **Key fix: reuse AudioEditorForm instance and set SelectionPath properly**
private void button1_Click(object sender, EventArgs e)
{
if (Voice_List.SelectedItem == null)
{
MessageBox.Show("Please select a voice file first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset and speaker first.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
SharedPath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem.ToString(),
Speaker_List.SelectedItem.ToString(),
Voice_List.SelectedItem.ToString());
Clipboard.SetText(SharedPath);
if (audioEditorForm == null || audioEditorForm.IsDisposed)
{
audioEditorForm = new AudioEditorForm();
}
audioEditorForm.SelectionPath = SharedPath;
if (!audioEditorForm.Visible)
{
audioEditorForm.Show();
}
else
{
audioEditorForm.BringToFront();
}
}
private void Speaker_List_SelectedIndexChanged(object sender, EventArgs e)
{
Voice_List.Items.Clear();
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
return;
string totalPath = Path.Combine(
DatasetHome,
Dataset_List.SelectedItem.ToString(),
Speaker_List.SelectedItem.ToString());
try
{
if (Directory.Exists(totalPath))
{
var files = Directory.GetFiles(totalPath)
.Where(f => f.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".wav", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".flac", StringComparison.OrdinalIgnoreCase));
foreach (var file in files)
{
Voice_List.Items.Add(Path.GetFileName(file));
}
}
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load voice files: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset and speaker to delete.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string TotalPath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), Speaker_List.SelectedItem.ToString());
if (!Directory.Exists(TotalPath))
{
MessageBox.Show("Selected speaker folder does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var confirmResult = MessageBox.Show($"Are you sure you want to delete the speaker folder '{Speaker_List.SelectedItem}' and all its contents?",
"Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (confirmResult != DialogResult.Yes)
return;
try
{
Directory.Delete(TotalPath, true);
var itemBackup = Speaker_List.SelectedItem;
Speaker_List.ClearSelected();
Speaker_List.Items.Remove(itemBackup);
Voice_List.Items.Clear();
Speaker_Name.Clear();
}
catch (Exception ex)
{
MessageBox.Show($"Failed to delete speaker folder: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public void OpenAndCopyAudioFiles()
{
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.Filter = "Audio Files (*.mp3;*.wav;*.flac)|*.mp3;*.wav;*.flac";
openFileDialog.FilterIndex = 1;
openFileDialog.Multiselect = true;
openFileDialog.Title = "Select audio files to copy";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
if (Dataset_List.SelectedItem == null || Speaker_List.SelectedItem == null)
{
MessageBox.Show("Please select a dataset and speaker before uploading files.", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string TotalPath = Path.Combine(DatasetHome, Dataset_List.SelectedItem.ToString(), Speaker_List.SelectedItem.ToString());
if (!Directory.Exists(TotalPath))
{
Directory.CreateDirectory(TotalPath);
}
foreach (string sourceFilePath in openFileDialog.FileNames)
{
string fileName = Path.GetFileName(sourceFilePath);
string destFilePath = Path.Combine(TotalPath, fileName);
try
{
File.Copy(sourceFilePath, destFilePath, overwrite: true);
if (!Voice_List.Items.Contains(fileName))
Voice_List.Items.Add(fileName);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to copy {fileName}: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
}
// Utility class for input dialogs (for renaming dataset)
public static class Prompt
{
public static string ShowDialog(string text, string caption, string defaultValue = "")
{
Form prompt = new Form()
{
Width = 400,
Height = 150,
FormBorderStyle = FormBorderStyle.FixedDialog,
Text = caption,
StartPosition = FormStartPosition.CenterParent,
MinimizeBox = false,
MaximizeBox = false
};
Label textLabel = new Label() { Left = 20, Top = 20, Text = text, AutoSize = true };
TextBox inputBox = new TextBox() { Left = 20, Top = 50, Width = 340 };
inputBox.Text = defaultValue;
Button confirmation = new Button() { Text = "OK", Left = 190, Width = 80, Top = 80, DialogResult = DialogResult.OK };
Button cancel = new Button() { Text = "Cancel", Left = 280, Width = 80, Top = 80, DialogResult = DialogResult.Cancel };
confirmation.Click += (sender, e) => { prompt.Close(); };
cancel.Click += (sender, e) => { prompt.Close(); };
prompt.Controls.Add(textLabel);
prompt.Controls.Add(inputBox);
prompt.Controls.Add(confirmation);
prompt.Controls.Add(cancel);
prompt.AcceptButton = confirmation;
prompt.CancelButton = cancel;
return prompt.ShowDialog() == DialogResult.OK ? inputBox.Text.Trim() : null;
}
}
}
```
---
### `AudioEditorForm.cs`
```csharp
using System;
using System.Windows.Forms;
namespace ByteBreath
{
public partial class AudioEditorForm : Form
{
private string selectionPath;
public string SelectionPath
{
get => selectionPath;
set
{
selectionPath = value;
UpdateUIWithSelectionPath();
}
}
public AudioEditorForm()
{
InitializeComponent();
}
private void UpdateUIWithSelectionPath()
{
if (!string.IsNullOrEmpty(selectionPath))
{
// Example: update UI controls or load audio file
// For example, if you have a textbox to show the path:
// this.textBoxPath.Text = selectionPath;
// Or call an audio player control to load the file at selectionPath
}
}
}
}
```
---
# Explanation / Notes
- Added a private field and a public property `SelectionPath` in `AudioEditorForm` that updates the form when set.
- In `DataSetMaker`, `button1_Click` reuses the same `AudioEditorForm` instance to avoid multiple windows and just sets `SelectionPath`.
- `Clipboard.SetText(SharedPath);` remains in place to expose the path to clipboard.
- If you need the audio loading or player logic inside `AudioEditorForm`, that should be implemented inside `UpdateUIWithSelectionPath()` or elsewhere triggered by this property.
- Derive the rest of your `AudioEditorForm` UI logic accordingly.
---
If you want me to help with the exact internals of `AudioEditorForm` loading audio files, just say so!41e549592c6876e7a5ab1b2fUser: Hi, what's up? User: Hi, what's up? Assistant:
Hello! Not much, just here and ready to help. How about you?
41e549592c6876e7a5ab1b2fUser: Hi, what's up? User: Hi, what's up? Assistant:
Hello! Not much, just here and ready to help. How about you?
41e549592c6876e7a5ab1b2fUser: Hi, what's up? User: Hi, what's up? Assistant:
Hello! Not much, just here and ready to help. How about you?
1e4982a673fa3013a8d8a09dUser: kumaha Lagu Malaysia User: kumaha Lagu Malaysia Assistant:
Halo! Naha anjeun nuju nyungkeun ngeunaan lagu-lagu ti Malaysia? Upami kitu, aya seueur lagu tradisional sareng modéren anu populér di Malaysia. Contona, lagu-lagu tradisional saperti "Rasa Sayang" atanapi lagu-lagu modéren ti penyanyi kawentar sapertos Siti Nurhaliza. Anjeun hoyong nyaho langkung seueur ngeunaan jinis lagu naon atanapi penyanyi naon? Atanapi anjeun hoyong kuring nyarankeun lagu-lagu ti Malaysia?
63650dd97169c16fe03e45d1User: hi, how are you? User: hi, how are you? Assistant:
Hello! I'm doing well, thank you. How can I assist you today?
41e549592c6876e7a5ab1b2fUser: Hi, what's up? User: Hi, what's up? Assistant:
Hello! Not much, just here and ready to help. How about you?