Skip to content

Commit

Permalink
update speech and ui
Browse files Browse the repository at this point in the history
  • Loading branch information
SanHacks committed Jan 27, 2024
1 parent ce8affb commit 4a00e8b
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 5 deletions.
1 change: 0 additions & 1 deletion Whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

type Response struct {
Text string `json:"text"`
// add other fields as needed
}

func Whisper(pathToFind string) string {
Expand Down
20 changes: 20 additions & 0 deletions aigenUi/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ func ChangeSetting(soundIsOn int) {
}
}

func ChangeVoice(provider string) {
db, err := sql.Open("sqlite3", SettingsDB)
if err != nil {
log.Printf("Error opening database: %v", err)
}
defer func(db *sql.DB) {
err := db.Close()
if err != nil {
log.Println(err)
}

}(db)

// Insert the keylogger into the database
_, err = db.Exec("INSERT INTO settings (speech_provider) VALUES (?)", provider)
if err != nil {
log.Printf("Error inserting into database: %v", err)
}
}

func SoundIsOffON(soundIsOff int) {
db, err := sql.Open("sqlite3", SettingsDB)
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions aigenUi/uiSettingsTab.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ func AudioSettingsTab() *container.TabItem {
return audioSettingsTab
}

func DualVoiceSettings() *container.TabItem {
DualVoice := container.NewTabItem("Dual Speech Settings",
widget.NewSelect([]string{"AzureSpeech", "OpenAI"}, func(value string) {
log.Println("Select set to", value)
//UpdateSpeechProvider(value)
}))
return DualVoice
}

func UpdateSpeechProvider(value string) {
ChangeVoice(value)
}

func AudioSettings(soundIsOn int) {
ChangeSetting(soundIsOn)
}
Expand Down
4 changes: 3 additions & 1 deletion aigenUi/windowSettings.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package aigenUi

import "fyne.io/fyne/v2"
import (
"fyne.io/fyne/v2"
)

var WindowSize = fyne.NewSize(1200, 1200)
var MainTitle = "Sage"
Expand Down
1 change: 1 addition & 0 deletions dbChef.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func createSettingsDatabase() error {
platform TEXT DEFAULT NULL,
audioOnly INTEGER DEFAULT 1,
theme TEXT DEFAULT 'auto',
voice TEXT DEFAULT 'AZURESPEECH',
language TEXT DEFAULT NULL,
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
accessToken TEXT DEFAULT NULL,
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func main() {

mapungubwe.Settings().SetTheme(theme.DarkTheme())
aigenUi.SwitchUp(mapungubwe)
playWelcomeSound()

tabs, inputBoxContainer := mainApp(mapungubwe)
window := mapungubwe.NewWindow(aigenUi.MainTitle)
Expand Down
3 changes: 2 additions & 1 deletion mainApp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ func mainApp(mapungubwe fyne.App) (*container.AppTabs, *container.Split) {
chatMediaTab := aigenUi.UserMedia()
//developerMode := aigenUi.Developer()
audioSettingsTab := aigenUi.AudioSettingsTab()
DualVoiceSettings := aigenUi.DualVoiceSettings()
//Create the tabs container and add the tabs to it
tabs := container.NewAppTabs(aiGen, //financeTab,
extendAI, chatMediaTab, settingsTab, audioSettingsTab)
extendAI, chatMediaTab, settingsTab, audioSettingsTab, DualVoiceSettings)

inputBoxContainer := SignInHandler(chat, tabs, aiGen)

Expand Down
14 changes: 12 additions & 2 deletions speech.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import (
)

const notificationSoundFile = "notification.mp3"
const welcomeNotificationSoundFile = "welcome.mp3"

func pressPlayAudio(messageCall string) (bool, string) {
//Azure Speech

//TODO:: Allow switching of speech providers to allow for easy management of resources in cases
//were Azure Speech starts to act real funny we can pull the plug real quick
//soundFileName, checkError := aigenRest.SpeakOut(messageCall)
//soundFileName, checkError := aigenRest.GCloudSpeakOUt(messageCall)
soundFileName, checkError := aigenRest.GptSpeakOut(messageCall)

if checkError == nil {
Expand All @@ -23,7 +27,6 @@ func pressPlayAudio(messageCall string) (bool, string) {
} else {
log.Println(checkError)
}

return true, soundFileName
}

Expand All @@ -41,6 +44,13 @@ func playVoiceNote(filename string) {
}
}

func playWelcomeSound() {
err := aigenAudioAutoPlay.PlayAudioPlayback(welcomeNotificationSoundFile)
if err != nil {
return
}
}

func getAudioFile(message string) {
audioFile, err := getAudio(message)
if err != nil {
Expand Down

0 comments on commit 4a00e8b

Please sign in to comment.