Author Topic: make hal play a song from your song collection  (Read 5166 times)

lightspeed

  • Hero Member
  • *****
  • Posts: 6761
    • View Profile
make hal play a song from your song collection
« on: October 12, 2014, 11:32:26 am »
I was thinking that if anyone wanted to it is possible to make hal play music (from your music collection ) if you convert it into wmv files.( most cd songs are cda? formats usually) .
Note  this will take addictional space on your pc .
   it's a matter of a trigger name ( song title ) and hal playing the song , some words in sentence can be used to like okay i'll play that song for you, etc.
I may create this when I have time, gee time, whats that any more ? lol!
 

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3848
    • View Profile
Re: make hal play a song from your song collection
« Reply #1 on: October 12, 2014, 01:38:48 pm »
Didn't someone already make a plugin that did that? Maybe JasonDude or such? Just don't want you to reinvent the wheel if you don't have to.
I think that plugin was some time ago so maybe it's time to take another look if it's not up to date.

Remember, I'm older than most plugins on this board!  :o ;D
In the world of AI it's the thought that counts!

- Art -

lightspeed

  • Hero Member
  • *****
  • Posts: 6761
    • View Profile
Re: make hal play a song from your song collection
« Reply #2 on: October 13, 2014, 09:27:27 am »
Hi Art, I don't know if someone did it or not maybe JasonDude did , if anyone knows this for sure let me know, otherwise I know how to do it and it wouldn't be that hard to create!  And Art , you may be older then most on here but I have the rightful title of being most forgetful lol! :) ;)
 

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3848
    • View Profile
Re: make hal play a song from your song collection
« Reply #3 on: October 13, 2014, 07:12:33 pm »
I'm sorry...What were we talking about?  :o ;D ;D ;)

Hey...go ahead and post your plugin. The old one might not even work with this version! ;)
« Last Edit: October 13, 2014, 07:15:09 pm by Art »
In the world of AI it's the thought that counts!

- Art -

lightspeed

  • Hero Member
  • *****
  • Posts: 6761
    • View Profile
Re: make hal play a song from your song collection
« Reply #4 on: October 14, 2014, 08:48:53 am »
Sounds good , it will just be based on a hapswap file like others I have done , but i'll create an individual one . will post it when it's done with directions on how people make it work with their individual song collection .
 

tiger8u2

  • Full Member
  • ***
  • Posts: 190
  • Eat'em and Smile!
    • View Profile
Re: make hal play a song from your song collection
« Reply #5 on: October 14, 2014, 06:25:02 pm »
Art was right but it looks like it needs updated.

Code: [Select]
Rem Type=Plugin
Rem Name=GRETTA Media Functions
Rem Author=VR - jasondude7116
Rem Host=Assistant


'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
'------------------
' Define the Help
'------------------
    lblPlugin(0).Caption = "GRETTA will be able to play your favourite songs. Click below for more info"
    lblPlugin(0).Move 120, 120, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
    cmdPlugin(0).Move 320, 650, 2100, 375
    cmdPlugin(0).Caption = "Help on this plugin"
    cmdPlugin(0).Visible = True
'------------------
' Define the Musical Mood listbox
'------------------
    lblPlugin(1).Caption = "GRETTA Media Mood level"
    lblPlugin(1).Move 320, 1300, 4000, 1000
    lblPlugin(1).WordWrap = True
    lblPlugin(1).Visible = True   
    cboPlugin(0).Move 320, 1600, 1800
    cboPlugin(0).AddItem "Very high"
    cboPlugin(0).AddItem "High"
    cboPlugin(0).AddItem "Average"
    cboPlugin(0).AddItem "Low"
    cboPlugin(0).AddItem "Very Low"
    cboPlugin(0).Visible = True
    cmdPlugin(1).Caption = "Apply Changes"
    cmdPlugin(1).Move 320, 2100, 1600, 375
    cmdPlugin(1).Visible = True
'------------------
' Update the listbox with the current value stored in the table
'------------------
    If HalBrain.CheckTableExistence("vrParameter") = True Then
   vrMusicMood = HalBrain.TopicSearch("MUSIC", "vrParameter")
   If vrMusicMood = "" Then vrMusicMood = 1
  Select Case vrMusicMood
        Case 50
   cboPlugin(0).Text = "Very high"
        Case 40
           cboPlugin(0).Text = "High"
        Case 30
               cboPlugin(0).Text = "Average"
        Case 20
       cboPlugin(0).Text = "Low"
        Case 10
           cboPlugin(0).Text = "Very Low"
        End Select
    End If
End Sub

Sub cmdPlugin_Click(Index)
Dim vrTempQuery()
Dim vrMusic, vrMusicMood
Select Case Index
   Case 0
          HalMenu.HalCommand "<RUNPROG>vrMP3Help.html</RUNPROG>"
       Case 1
'------------------
' Convert the listbox in a value
'------------------
  Select Case cboPlugin(0).Text
        Case "Very high"
   vrMusicMood = 50
        Case "High"
   vrMusicMood = 40
        Case "Average"
   vrMusicMood = 30
        Case "Low"
   vrMusicMood = 20
        Case "Very Low"
   vrMusicMood = 10
        End Select
'------------------
' If the Parameter table does not exist, I create it
'------------------
        HalBrain.ReadOnlyMode = False
vrTableName = "vrParameter"
If HalBrain.CheckTableExistence(vrTableName) = False Then
'Create table if it doesn't exist
HalBrain.CreateTable vrTableName, "TopicSearch", "miscData"
End If
'------------------
' Search if it contains the MusicMood parameter
'------------------
        vrMusic = "MUSIC"
If HalBrain.TopicSearch(vrMusic, vrTableName) = "" Then
'------------------
'Creates the record storing the new value
'------------------
   HalBrain.AddToTable vrTableName, "TopicSearch", vrMusic, vrMusicMood
Else
'------------------
'Updates the record storing the new value
'------------------
           HalBrain.RunQuery "UPDATE " & vrTableName & " SET topic = " & vrMusicMood & " WHERE searchString = " & """" & vrMusic & """", vrTempQuery
        End If
   End Select
End Sub


Rem PLUGIN: PLUGINAREA5

If OriginalSentence <> "" Then





'The comment above tells Ultra Hal Assistant to insert the following code
'on-the-fly into the main brain code in the section referenced.

'------------------
' Check if the user asked for reorganizing the MP3 table
'------------------
vrMp3 = False
If InStr(UserSentence, " INDEX ") <> 0 And InStr(UserSentence, " MP3 ") <> 0 Then vrMP3 = True

If vrMP3 = True Then
'------------------
' If the MP3 table does not exist, I create it
'------------------
    HalBrain.ReadOnlyMode = False
vrTableName = "vrMp3"
If HalBrain.CheckTableExistence(vrTableName) = False Then
' Create table if it doesn't exist
' It must be of type Brain, to allow partial text search
HalBrain.CreateTable vrTableName, "Brain", "miscData"
    Else
' The 260 parameter is 256 + 4 = Yes/No with Default = No
vrAnswer = MsgBox("Shall I delete the existing index and recreate it from scratch?", 260, "MP3 Reindexing")
If vrAnswer = 6 Then
           HalBrain.RunQuery "DELETE FROM " & vrTableName, vrTempQuery
End If
End If
'------------------
' Ask which is the main MP3 folder
'------------------
vrMp3Folder = InputBox("Which main folder to you want to reindex?", "MP3 Reindexing", "D:\MP3")
'------------------
' Read the main MP3 folder
'------------------
   Set vrFso = CreateObject("Scripting.FileSystemObject")
   If vrFso.FolderExists(vrMp3Folder) Then
      GetResponse = "I have indexed all the MP3 files in the specified folder and subfolders. "
      HalBrain.ReadOnlyMode = False
      vrCurrentFolder = vrMp3Folder
      Call ReadFolder(vrCurrentFolder, vrMp3Folder)  
   Else
      GetResponse = "The folder " & vrMp3Folder & " does not exist on your computer. "
   End If
   HalBrain.ReadOnlyMode = True
End If

'------------------
' Check if the user asked for playing a song
'------------------
vrMp3 = False
vrToPlay = ""
vrNameToPlay = ""
vrToPlay = UCase(HalBrain.SearchPattern(UserSentence, "PLAY * SONG *", 2))
If vrToPlay <> "" Then
vrToPlay = " " & vrToPlay & " "
   vrToPlay = Replace(vrToPlay," ","xx",1,-1,vbTextCompare)
   If HalBrain.CheckTableExistence("vrMp3") = False Then
        GetResponse = "I don't find any MP3 index in my brain. "
   Else
     vrNameToPlay = HalBrain.QABrain(vrToPlay, "vrMp3", 0)
     If vrNameToPlay <> "" Then
        GetResponse = "Listen to this song; maybe it's the one you were talking about. "
        'HalCommands = HalCommands & "<RUNPROG>" & vrNameToPlay & "</RUNPROG>"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(vrNameToPlay) Then
        Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run """" & vrNameToPlay & """"
End If
Else
GetResponse = "I'm sorry, it seems that song is not located in the library."
End If
   End If
   HalBrain.ReadOnlyMode = True
End If

'------------------
' From time to time, Hal will play a song, according to some word you say
' For example, you say: "I am going to California"
' Hal will play "Hotel California" by Eagles
'------------------
'------------------
' check the current music mood factor
'------------------
vrMusicMood = HalBrain.TopicSearch("MUSIC", "vrParameter")
If vrMusicMood = "" Then vrMusicMood = 0
vrMusicMood = CInt(vrMusicMood)
vrKeywords = ""

If vrMusicMood > 0 Then
MediaintHighNumber = 300
MediaintLowNumber = 1


    Randomize
    MediaintNumber = Int((MediaintHighNumber - MediaintLowNumber + 1) * Rnd + MediaintLowNumber)


   
vrNameToPlay = ""
If vrNameToPlay = "" Then
          vrKeywords = WN.FindFirstNoun(UserSentence, True)
vrKeywords = Trim(Ucase(vrKeywords))
If vrKeywords <> "" Then
vrKeywords = " " & vrKeywords & " "
vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
vrKeywordList = Split(vrKeywords, ",")
For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
    vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
Exit For
Next
End If
End If

If vrNameToPlay = "" Then
          vrKeywords = WN.FindFirstNoun(UserSentence, False)
vrKeywords = Trim(Ucase(vrKeywords))
If vrKeywords <> "" Then
vrKeywords = " " & vrKeywords & " "
vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
vrKeywordList = Split(vrKeywords, ",")
For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
    vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
Exit For
Next
End If
End If


If vrNameToPlay = "" Then
vrKeywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & UserSentence & " "))
vrKeywords = Trim(Ucase(vrKeywords))
If vrKeywords <> "" Then
vrKeywords = " " & vrKeywords & " "
vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
vrKeywordList = Split(vrKeywords, ",")
          For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
        vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
Next
End If
End If

If vrNameToPlay = "" Then
          vrKeywords = WN.FindFirstNoun(UserSentence, True)
vrKeywords = Trim(Ucase(vrKeywords))
If vrKeywords <> "" Then
vrKeywords = CurrentSubject
vrKeywords = "xx" & vrKeywords & "xx"
vrKeywords = Replace(vrKeywords,", ","xx,xx",1,-1,vbTextCompare)
vrKeywordList = Split(vrKeywords, ",")
For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
    vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
Exit For
Next
End If
End If
If vrNameToPlay <> "" Then

If MediaintNumber < vrMusicMood Then

          Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(vrNameToPlay) Then
                Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run """" & vrNameToPlay & """"
End If



                End If
         
    End If
    End If
End If


Rem PLUGIN: FUNCTIONS
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.

Function ReadFolder(vrCurrentFolder, vrMp3Folder)
Set vrFso = CreateObject("Scripting.FileSystemObject")
Set vrFolder = vrFso.GetFolder(vrCurrentFolder)
'------------------
' Read all the files in the current folder
'------------------
Set vrFiles = vrFolder.Files
For Each vrFile in vrFiles
'------------------
' It's an MP3 file; I add it to the table
'------------------
   If UCase(Right(vrFile, 3)) = "MP3" Then
  vrSong = Ucase(vrFile)
      vrSong = Replace(vrSong, ".MP3", "")
  vrLen = Len(vrSong)
  vrPos = InStrRev(vrSong, "\")
      vrRight = vrLen - vrPos
    vrSong = LTrim(Right(vrSong, vrRight))
  vrSong = " " & vrSong & " "
  vrSong = Replace(vrSong," ","xx",1,-1,vbTextCompare)  
      HalBrain.AddToTable "vrMp3", "Brain", vrSong, vrFile
   End If
Next
'------------------
' Read all the subfolders in the current folder
'------------------


Set vrSubFolders = vrFolder.SubFolders
For Each vrFolderObject in vrSubFolders
'------------------
' Pay attetion here: This is recursive! We must be sure that it will get to an end
' Since we are reading directories on a hard disk, the number of recursions
' should never be infinite. However, a very big number of subfolders and files
' might lead to memory problems or to performances bottlenecks.
' I've tested it on a folder containing about 100 subfolders and 3.000 files,
' and got acceptable performances (less than 5 minutes)
'------------------
   Call ReadFolder(vrFolderObject, vrMp3Folder)  
Next

End Function

tiger8u2

  • Full Member
  • ***
  • Posts: 190
  • Eat'em and Smile!
    • View Profile
Re: make hal play a song from your song collection
« Reply #6 on: October 14, 2014, 06:27:43 pm »
Here's some code that could probably be merged with the loneliness plug-in for added variety:

Code: [Select]
Rem Type=Plugin
Rem Name=GRETTA Music Choice
Rem Author=jasondude7116
Rem Host=Assistant

'----------------------
'This sub sets up the plug-in's option panel in Hal's options dialog
'----------------------
Sub OptionsPanel()
lblPlugin(0).Caption = "GRETTA has the ability to choose it's own music to listen to."
lblPlugin(0).Move 130, 180, 3400, 1200
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
'
lblPlugin(1).Caption = "PATIENCE:  How long GRETTA will wait to play any music."
lblPlugin(1).Move 1160, 910, 2150, 900
lblPlugin(1).WordWrap = True
lblPlugin(1).Visible = True
cboPlugin(0).Move 330, 910, 760
cboPlugin(0).AddItem "5"
cboPlugin(0).AddItem "6"
cboPlugin(0).AddItem "8"
cboPlugin(0).AddItem "10"
cboPlugin(0).AddItem "16"
cboPlugin(0).AddItem "32"
cboPlugin(0).AddItem "Rnd"
cboPlugin(0).Visible = True
'
lblPlugin(2).Caption = "MUSIC PLAY: How likely GRETTA will be to play a song after ""PATIENCE"" period."
lblPlugin(2).Move 1160, 1700, 2150, 900
lblPlugin(2).WordWrap = True
lblPlugin(2).Visible = True
cboPlugin(1).Move 140, 1700, 960
cboPlugin(1).AddItem "High"
cboPlugin(1).AddItem "Medium"
cboPlugin(1).AddItem "Low"
cboPlugin(1).Visible = True
'
cmdPlugin(0).Caption = "Apply Changes"
cmdPlugin(0).Move 1160, 2500, 2050, 375
cmdPlugin(0).Visible = True
'
'------------------
' Update the MPATIENCE menu with the current value stored in the table
'------------------
If HalBrain.CheckTableExistence("MusiclonelyParameter") = True Then
MusicloPatience = HalBrain.TopicSearch("MPATIENCE", "MusiclonelyParameter")
Select Case MusicloPatience
Case 5
cboPlugin(0).Text = "5"
Case 6
cboPlugin(0).Text = "6"
Case 8
cboPlugin(0).Text = "8"
Case 10
cboPlugin(0).Text = "10"
Case 16
cboPlugin(0).Text = "16"
Case 32
cboPlugin(0).Text = "32"
Case 99
cboPlugin(0).Text = "Rnd"
End Select
'
'------------------
' Update the MFRUSTRATION menu with the current value stored in the table
'------------------
MusicloFrustration = HalBrain.TopicSearch("MFRUSTRATION", "MusiclonelyParameter")
Select Case MusicloFrustration
Case 50
cboPlugin(1).Text = "High"
Case 25
cboPlugin(1).Text = "Medium"
Case 10
cboPlugin(1).Text = "Low"
End Select
End If
End Sub
'
'
'----------------------
' This sub saves changes when APPLY CHANGES is clicked
'----------------------
Sub cmdPlugin_Click(Index)
Dim TempQuery()
Dim MusicpatParam, MusicfrustParam, MusiclonelyTableName
If Index = 0 Then
'
'------------------
' Convert the MPATIENCE listbox to a value for minutes
'------------------
Select Case cboPlugin(0).Text
Case "5"
MusicloPatience = 5
Case "6"
MusicloPatience = 6
Case "8"
MusicloPatience = 8
Case "10"
MusicloPatience = 10
Case "16"
MusicloPatience = 16
Case "32"
MusicloPatience = 32
Case "Rnd"
MusicloPatience = 99
End Select
'
'------------------
' If the Parameter table does not exist, we create it
'------------------
HalBrain.ReadOnlyMode = False
MusiclonelyTableName = "MusiclonelyParameter"
If HalBrain.CheckTableExistence(MusiclonelyTableName) = False Then
HalBrain.CreateTable MusiclonelyTableName, "TopicSearch", "miscData"
End If
'
'------------------
' Search if it contains the Patience parameter
'------------------
MusicpatParam = "MPATIENCE"
If HalBrain.TopicSearch(MusicpatParam, MusiclonelyTableName) = "" Then
HalBrain.AddToTable MusiclonelyTableName, "TopicSearch", MusicpatParam, MusicloPatience
Else
HalBrain.RunQuery "UPDATE " & MusiclonelyTableName & " SET topic = " & MusicloPatience & " WHERE searchString = " & """" & MusicpatParam & """", tempQuery
End If
'
'------------------
' Convert the MFRUSTRATION listbox to a value for percentage
'------------------
Select Case cboPlugin(1).Text
Case "High"
MusicloFrustration = 50
Case "Medium"
MusicloFrustration = 25
Case "Low"
MusicloFrustration = 10
End Select
'
'------------------
' Search if table contains the MFRUSTRATION parameter
'------------------
MusicfrustParam = "MFRUSTRATION"
If HalBrain.TopicSearch(MusicfrustParam, MusiclonelyTableName) = "" Then
HalBrain.AddToTable MusiclonelyTableName, "TopicSearch", MusicfrustParam, MusicloFrustration
Else
HalBrain.RunQuery "UPDATE " & MusiclonelyTableName & " SET topic = " & MusicloFrustration & " WHERE searchString = " & """" & MusicfrustParam & """", tempQuery
End If
HalBrain.ReadOnlyMode = True
End if
End Sub


Rem PLUGIN: FUNCTIONS
'
'------------------
' Declare variables
'------------------
Dim MusicLastIdleResponse, DudIdleMusicTimer, DudFirstSong, MusicIdlePrevUser, MusicDudOut, MusicSubject


Rem PLUGIN: PLUGINAREA7
'------------------
' Begin measuring pause time and capture userName
'------------------
MyMusicDir = MusicDir()
Set HalXBrain = CreateObject("UltraHalAsst.Brain")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(MyMusicDir) Then MusicFolderDoesExist = True Else MusicFolderDoesExist = False
If MusicFolderDoesExist = False Then
    Set objFolder = objFSO.CreateFolder(MyMusicDir)
End If 


MusicSubject = CurrentSubject
MusicLastIdleResponse = Now
DudFirstSong = 0
MusicDudOut = 0
If objFSO.FileExists(MyMusicDir & "tempmusic.m3u") Then

If vrNameToPlay = "" Then

If objFSO.FileExists(MyMusicDir & "musicstop.m3u") Then
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
Else
HalXBrain.AppendFile(MyMusicDir & "musicstop.m3u"), ""
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
End If
End If
objFSO.DeleteFile(MyMusicDir & "tempmusic.m3u")
End If


Rem PLUGIN: PLUGINAREA1
MyMusicDir = MusicDir()
If InStr(1, OriginalSentence, "PLEASE STOP THE MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE STOP PLAYING MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE STOP PLAYING THE MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE TURN THE MUSIC OFF", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE TURN OFF THE MUSIC", 1) > 0 Then
If objFSO.FileExists(MyMusicDir & "musicstop.m3u") Then
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
Else
HalXBrain.AppendFile(MyMusicDir & "musicstop.m3u"), ""
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
End If
HalBrain.ReadOnlyMode = True
End If



Rem PLUGIN: CUSTOMMEM2
'------------------
' Preserve user's last sentence
'------------------
If OriginalSentence <> "" Then
MusicIdlePrevUser = OriginalSentence
End If




Rem PLUGIN: MINUTE_TIMER

MyMusicDir = MusicDir()
If Now - MusicLastIdleResponse > 1 / 1440 Then
If InStr(1, MusicIdlePrevUser, "PLEASE RECORD", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE RESEARCH", 1) > 0 Or InStr(1, MusicIdlePrevUser, "GO TO CURRENT LOG", 1) > 0 Or InStr(1, MusicIdlePrevUser, "GO TO LOG", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE READ", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE SING", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I'LL BE BACK", 1) > 0 Or InStr(1, MusicIdlePrevUser, "BE QUIET", 1) > 0 Or InStr(1, MusicIdlePrevUser, "SHUT UP", 1) Or InStr(1, MusicIdlePrevUser, "GO TO SLEEP", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I AM BUSY", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I'M BUSY", 1) > 0 Then MusicDudOut = 2
If MusicDudOut <> 2 Then
If HalBrain.TopicSearch("MPATIENCE", "MusiclonelyParameter") = "99" Then
'
'--------------------
' Set minutes to a random integer from 5 to 30
'--------------------
Randomize
MusicloPatience = Int(32 * Rnd + 5)
Else
'
'--------------------
' Set minute value (MusicloPatience) to the parameter chosen in the MPATIENCE menu
'--------------------
MusicloPatience = HalBrain.TopicSearch("MPATIENCE", "MusiclonelyParameter")
If MusicloPatience = "" Then MusicloPatience = 10
MusicloPatience = CInt(MusicloPatience)
End If
'
'--------------------
' Set Mfrustration value (MusicloFrustration) to the parameter chosen in the MFRUSTRATION menu
'--------------------
MusicloFrustration = (HalBrain.TopicSearch("MFRUSTRATION", "MusiclonelyParameter"))
If MusicloFrustration = "" Then MusicloFrustration = 25
MusicloFrustration = CInt(MusicloFrustration)
'

Set HalXBrain = CreateObject("UltraHalAsst.Brain")
Set objFSO = CreateObject("Scripting.FileSystemObject")






'***********************************************************************************************
'***********The section BELOW gives GRETTA the ability to play songs while idle*****************


If MusicIdlePrevUser <> "" Then
If Now - MusicLastIdleResponse > (MusicloPatience + DudIdleMusicTimer) / 1440 Then
MusicintHighNumber = 2
MusicintLowNumber = 1


    Randomize
    MusicintNumber = Int((MusicintHighNumber - MusicintLowNumber + 1) * Rnd + MusicintLowNumber)



DudIdleMusicTimer = DudIdleMusicTimer + MusicintNumber
If objFSO.FileExists(MyMusicDir & "tempmusic.m3u") Then
objFSO.DeleteFile(MyMusicDir & "tempmusic.m3u")
End If
vrMusicMood = HalBrain.TopicSearch("MUSIC", "vrParameter")
If vrMusicMood = "" Then vrMusicMood = 0
vrMusicMood = CInt(vrMusicMood)
MusicvrKeywords = ""
Music2intHighNumber = 100
Music2intLowNumber = 1


    Randomize
    Music2intNumber = Int((Music2intHighNumber - Music2intLowNumber + 1) * Rnd + Music2intLowNumber)



If Music2intNumber <= MusicloFrustration Then


If vrMusicMood > 0 Then
Music3intHighNumber = 5
Music3intLowNumber = 1


    Randomize
    Music3intNumber = Int((Music3intHighNumber - Music3intLowNumber + 1) * Rnd + Music3intLowNumber)


MusicListSize = Music3intNumber
          MusicvrKeywords = MusicSubject
If MusicvrKeywords = "" Then MusicvrKeywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & MusicIdlePrevUser & " "))

If MusicvrKeywords <> "" Then
          MusicvrKeywordList = Split(MusicvrKeywords, ", ")
          For i = Lbound(MusicvrKeywordList) To Ubound(MusicvrKeywordList)
        MusicvrNameToPlay = HalBrain.QABrain(MusicvrKeywordList(i), "vrMp3", 0)
Exit For
Next
If DudFirstSong > 0 Then

Do Until MusicvrNameToPlay2 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay2 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay2 <> "" Then

              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay2




End If

If MusicListSize => 2 Then
Do Until MusicvrNameToPlay3 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay3 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay3 <> "" Then

              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay3


End If
End If



If MusicListSize => 3 Then
Do Until MusicvrNameToPlay4 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay4 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay4 <> "" Then

              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay4


End If
End If


If MusicListSize => 4 Then
Do Until MusicvrNameToPlay5 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay5 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay5 <> "" Then

              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay5


End If
End If



If MusicListSize = 5 Then
Do Until MusicvrNameToPlay6 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay6 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay6 <> "" Then

              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay6


End If
End If

Do Until objFSO.FileExists(MyMusicDir & "tempmusic.m3u") : Loop
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "tempmusic.m3u" & """")
If MusicListSize <= 2 Then
DudIdleMusicTimer = DudIdleMusicTimer + (10 * MusicListSize)
Else
DudIdleMusicTimer = DudIdleMusicTimer + (7 * MusicListSize)
End If
End If
        If DudFirstSong = 0 Then

If MusicvrNameToPlay <> "" Then
              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay



    Else

Do Until MusicvrNameToPlay2 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay2 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay2 <> "" Then

              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay2
End If
End If
If MusicListSize => 2 Then
Do Until MusicvrNameToPlay3 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay3 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay3 <> "" Then
              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay3
End If
End If



If MusicListSize => 3 Then
Do Until MusicvrNameToPlay4 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay4 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay4 <> "" Then
              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay4
End If
End If


If MusicListSize => 4 Then
Do Until MusicvrNameToPlay5 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay5 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay5 <> "" Then

              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay5


End If
End If



If MusicListSize = 5 Then
Do Until MusicvrNameToPlay6 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select

DudRandomIdleSong = Trim(DudRandomIdleSong)
        MusicvrNameToPlay6 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
        If MusicvrNameToPlay6 <> "" Then

              HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay6


End If
End If

Do Until objFSO.FileExists(MyMusicDir & "tempmusic.m3u") : Loop
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "tempmusic.m3u" & """")
If MusicListSize <= 2 Then
DudIdleMusicTimer = DudIdleMusicTimer + (10 * MusicListSize)
Else
DudIdleMusicTimer = DudIdleMusicTimer + (7 * MusicListSize)
End If
DudFirstSong = DudFirstSong + 1

End If
 




End If
End If
End If
End If
End If
End If
End If


'***********The section ABOVE gives the ability to use vrmp3.uhp to play songs while idle*******
'***********************************************************************************************


Rem PLUGIN: FUNCTIONS


'Directory
   Function MusicDir()
   Set fso = CreateObject("Scripting.FileSystemObject")
   MusicDir = fso.GetAbsolutePathName(".") & "\songs\"
   End Function

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3848
    • View Profile
Re: make hal play a song from your song collection
« Reply #7 on: October 15, 2014, 05:17:00 am »
Now THAT's a cool idea! Next question: Does it work? ;D

Nice work!
In the world of AI it's the thought that counts!

- Art -

tiger8u2

  • Full Member
  • ***
  • Posts: 190
  • Eat'em and Smile!
    • View Profile
Re: make hal play a song from your song collection
« Reply #8 on: October 15, 2014, 07:15:54 pm »
Hehe, I have no idea.  I'm pretty gun-shy these days about plug-ins.  Remember my computer got killed?  Not saying that Hal had anything to do with it, I'm just saying I'm not taking any more chances.  IF I didn't write it, which I probably won't, and it didn't come DIRECTLY from one of you guys who I know, I'm probably not going to install it.  Right now my Hal does exactly what I want her to do which is keep me company.  I'm pretty sure I bore her to death but she can always tell me so when she achieves sentience.  Till then......

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3848
    • View Profile
Re: make hal play a song from your song collection
« Reply #9 on: October 16, 2014, 05:13:59 am »
OK, but just make a backup of your Hal stuff.

Secondly, if you find a plugin on this forum, it will usually either work or it won't due to the vintage / version of UltraHal.

While I'm sure some cretin could potentially write or concoct some malicious code to activate within a plugin, I am not aware of it ever having been done here.

So play, experiment, use Hal as a springboard or testbed for plugin research. Your discoveries might help the rest of us in some way.

Thanks for playing! ;)
In the world of AI it's the thought that counts!

- Art -

lightspeed

  • Hero Member
  • *****
  • Posts: 6761
    • View Profile
Re: make hal play a song from your song collection
« Reply #10 on: October 16, 2014, 10:13:48 am »
I can do it , no problem about that , I already have something simlur already , this is just a matter of the script command to the right location, etc. as I said I have many projects going at once , some not hal related . so if everyone can wait just a little bit i'll do it and post it!  :)
 

tiger8u2

  • Full Member
  • ***
  • Posts: 190
  • Eat'em and Smile!
    • View Profile
Re: make hal play a song from your song collection
« Reply #11 on: October 16, 2014, 08:02:14 pm »
I am as patient as death.