I am using sqlite-net-pcl as my database in my xamarin forms project.
This is my table to create text to label that audio:
[Table("SpeechRecTable")] [Serializable] public class SpeechRecTable { [PrimaryKey] public int Id { get; set; } public string Text { get; set; } public string Speech { get; set; } public override string ToString() { return string.Format("[User: Id={0}, Text={1}, Speech={2}]", Id, Text, Speech); } }
I still haven't used the "Speech" part of this.
Based on my research, I can store audio the same way you store images. I am new in xamarin an I am still 1 month in learning this. So I dont have any knowledge on how to do it. I still didn't find any good documentation for storing audio (.wav).
This is my code for audio recording, and it only lets me record 1 audio and when I record another the last recorded audio will be gone. I want to access all my recorded audio in another page with their specified text label.
try { var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Microphone); //await DisplayAlert("Pre - Results wat", status.ToString(), "OK"); if (!recorder.IsRecording) { recorder.StopRecordingOnSilence = TimeoutSwitch.IsToggled; RecEditor.IsEnabled = false; PlayButton.IsEnabled = false; //Start recording var audioRecordTask = await recorder.StartRecording(); BtnDoneRec.IsEnabled = false; await audioRecordTask; PlayButton.IsEnabled = true; } else { RecEditor.IsEnabled = true; BtnDoneRec.IsEnabled = true; //stop recording ... await recorder.StopRecording(); } if (status != PermissionStatus.Granted) { status = await Utils.CheckPermissions(Permission.Microphone); //await DisplayAlert("Results", status.ToString(), "OK"); } } catch (Exception ex) { //blow up the app! await DisplayAlert("Error", ex.Message, "OK"); }
This is the play button code:
try { var filePath = recorder.GetAudioFilePath(); if (filePath != null) { player.Play(filePath); } } catch (Exception ex) { //blow up the app! await DisplayAlert("Error", ex.Message, "OK"); }
I am using android for this project.