Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Added Control Centre support
Browse files Browse the repository at this point in the history
Preparing for AutomneOS Samoyed
  • Loading branch information
lesterrry authored Mar 28, 2021
1 parent c723ca9 commit a5e8197
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 128 deletions.
229 changes: 128 additions & 101 deletions AutomneAxioms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,101 +17,126 @@ class AutomneAxioms{
public static let SCTailQueue = "?client_id="

public static let emojis = ["📡", "🎛", "🎚", "🎙", "📻", "📀", "💿", "💽", "🌌", "🎹", "🎧", "🎤", "🍂", "🍁", "🦗", "🌤", "🦊", "🎃", "🌲", "🥘", "🚲", "🚉", "🏕", "🛤", "🗺"]
public static var messages = ["You are loved.",
"You are not alone.",
"Я не помню, как я оказался в лесу",
"These are my friends",
"Leaves are always yellow in Golovkovo",
"Smash the government",
"You always have a chance.",
"Don't forget who you are",
"Nature is fascinating",
"This is from Matilda",
"We watched the end of the century, compressed on a tiny screen",
"At every occasion, i'll be ready for the funeral",
"To see age in a flower, the dawns are speeding up",
"Life's alright in devil town",
"Увидимся в Лапшичной",
"В Хижине на Холме чай пахнет ёлками",
"Не бросайте своих собак",
"Ветер воет в форточках Полустанка",
"Why would dogs avoid these hills?",
"@phvkha is the best photographer i've ever known",
"You're welcome anytime in my dreams",
"Apocalypse",
"Life is a drink, and love's a drug",
"I never meant to cause you trouble",
"Истории Петербурга – одни из лучших историй",
"You're standing out in the rain tonight",
"I love my grandparents",
"TIL I DIE DIE DIE",
"Nothing's terrible with friends around",
"Навсегда юность, навсегда смерть",
"Au sе́maphore ton nom rе́sonne",
"I used to fit in your arms, like a book in a shelf",
"Now I sit on the floor, telling jokes to myself",
"Я снова проспал и проснулся в обед",
"Прости, я забыл, что тебя нет",
"I won't hurt you, I won't hurt you",
"I'll tell you, Fenn, i'll tell you, when",
"It's now",
"I love you.",
"You're always welcome to Pokrovka Dacha",
"You are valid",
"Все в порядке, все пройдет",
"Утро которым мы умрем",
"You, you feel like Oxford blood",
"Where goes that path through the woods?",
"There goes our love again",
"Я встречусь с тобой осенью восьмого класса",
"Born in Possum Springs",
"R.I.P. Grandma",
"R.I.P. Alec",
"Ew a furry",
"Caring is the coolest thing I've seen anyone do.",
"It was a nice holiday without you",
"And it's called jazz",
"It's the colours you have, no need to be sad",
"Are you ready for the Longest Night?",
"And I think we'd survive in the wild",
"Слушать старые пластинки",
"I only have one thing in my head",
"Пойдем фоткаться на пленку",
"Гоу в Балчуг после уроков",
"Я такой один, мне не нужно притворяться",
"#038",
"26.04.2019 – ∞",
"Please, if you hear me, go away",
"Все получится",
"И тебе приснится целый мир без меня",
"Я заберу тебя танцевать",
"Знаешь, я так соскучился",
"Lavender is always running through my blood",
"Trapped in a club",
"All we had to do was touch",
"Spies hide out in every corner",
"Tears falling down at the party",
"Saddest little baby in the room",
"Еще одну бессонную ночь я посвящаю тебе",
"Поды для джула вкуснее всего в Люберцах",
"This couldn't happen again",
"I'd rather dissolve than have you ignore me",
"I miss the Weird Autumn",
"Сountryside sceneries hardly change",
"the holes of my sweater",
"blood like wine",
"Вишенку так я и не достал",
"Хочу Цезарь из Царского Села",
"В ЦДМ есть Шоколадница",
"Я смешаю коньяк и Байкал",
"Two oceans in between us",
"I left you at the farm",
"We had a good time, didn't we?",
"Drink at the casino all night",
"sunsets i wanna hear your voice",
"God Bless My Socially Retarded Friends",
"Лето тупо класс",
"хочу питсы"]
public static var messages = [
"You are loved.",
"You are not alone.",
"Я не помню, как я оказался в лесу",
"These are my friends",
"Leaves are always yellow in Golovkovo",
"Smash the government",
"You always have a chance.",
"Don't forget who you are",
"Nature is fascinating",
"This is from Matilda",
"We watched the end of the century, compressed on a tiny screen",
"At every occasion, i'll be ready for the funeral",
"To see age in a flower, the dawns are speeding up",
"Life's alright in devil town",
"Увидимся в Лапшичной",
"В Хижине на Холме чай пахнет ёлками",
"Не бросайте своих собак",
"Ветер воет в форточках Полустанка",
"Why would dogs avoid these hills?",
"@phvkha is the best photographer i've ever known",
"You're welcome anytime in my dreams",
"Apocalypse",
"Life is a drink, and love's a drug",
"I never meant to cause you trouble",
"Истории Петербурга – одни из лучших историй",
"You're standing out in the rain tonight",
"I love my grandparents",
"TIL I DIE DIE DIE",
"Nothing's terrible with friends around",
"Навсегда юность, навсегда смерть",
"Au sе́maphore ton nom rе́sonne",
"I used to fit in your arms, like a book in a shelf",
"Now I sit on the floor, telling jokes to myself",
"Я снова проспал и проснулся в обед",
"Прости, я забыл, что тебя нет",
"I won't hurt you, I won't hurt you",
"I'll tell you, Fenn, i'll tell you, when",
"It's now",
"I love you.",
"You're always welcome to Pokrovka Dacha",
"You are valid",
"Все в порядке, все пройдет",
"Утро которым мы умрем",
"You, you feel like Oxford blood",
"Where goes that path through the woods?",
"There goes our love again",
"Я встречусь с тобой осенью восьмого класса",
"Born in Possum Springs",
"R.I.P. Grandma",
"R.I.P. Alec",
"Ew a furry",
"Caring is the coolest thing I've seen anyone do.",
"It was a nice holiday without you",
"And it's called jazz",
"It's the colours you have, no need to be sad",
"Are you ready for the Longest Night?",
"And I think we'd survive in the wild",
"Слушать старые пластинки",
"I only have one thing in my head",
"Пойдем фоткаться на пленку",
"Гоу в Балчуг после уроков",
"Я такой один, мне не нужно притворяться",
"#038",
"26.04.2019 – ∞",
"Please, if you hear me, go away",
"Все получится",
"И тебе приснится целый мир без меня",
"Я заберу тебя танцевать",
"Знаешь, я так соскучился",
"Lavender is always running through my blood",
"Trapped in a club",
"All we had to do was touch",
"Spies hide out in every corner",
"Tears falling down at the party",
"Saddest little baby in the room",
"Еще одну бессонную ночь я посвящаю тебе",
"Поды для джула вкуснее всего в Люберцах",
"This couldn't happen again",
"I'd rather dissolve than have you ignore me",
"I miss the Weird Autumn",
"Сountryside sceneries hardly change",
"the holes of my sweater",
"blood like wine",
"Вишенку так я и не достал",
"Хочу Цезарь из Царского Села",
"В ЦДМ есть Шоколадница",
"Я смешаю коньяк и Байкал",
"Two oceans in between us",
"I left you at the farm",
"We had a good time, didn't we?",
"Drink at the casino all night",
"sunsets i wanna hear your voice",
"God Bless My Socially Retarded Friends",
"Лето тупо класс",
"хочу питсы",
"Застрять, как зубная нить между собачьими клыками",
"To the Neon District",
"Да ну его, это чистое сердце. Шоколад, по моему, гораздо лучше",
"Старость – самая большая неожиданность в жизни",
"We missed you a lot",
"Welcome back",
"Lester hugs you for using Automne",
"Радио Осень – всегда в прямом эфире",
"В мире много бессмыслицы",
"Что может быть бессмысленнее, чем проснуться утром одному в номере интим-гостиницы?",
"Апрель – слишком грустная пора, чтобы проводить ее в одиночестве",
"Одни, скинув тяжелые куртки, беседовали на солнышке",
"Другие играли в кэтч-бол",
"Третьи любили",
"А я был полностью одинок",
"Вдобавок ко всему, я был влюблен",
"И любовь эта привела меня в очень непростое место",
"Неудовлетворенное страстное желание отрочества",
"Мир просторен",
"Общаясь с ним, иногда ловишь себя на мысли, что ходишь по кругу",
"Кассетная камера всегда под рукой",
"Magic happens when cassettes are being recorded",
"Hold on, let me find my walkman"
]

public static let trackNarratives = [
("Now playing", true),
Expand All @@ -128,11 +153,6 @@ class AutomneAxioms{
("that's the $", false),
("is up to your ears", false)
]
public static var specialNarratives = [
"Welcome back",
"Never settle",
"We missed you a lot"
]
public static let specialTimeNarratives = [
"morning": [
"Good morning",
Expand All @@ -144,7 +164,7 @@ class AutomneAxioms{
"Вот оно, утро, с которого надо начинать день"
],
"day": [
"This day is great, is not it?",
"This day is great, isn't it?",
"Autumn brings music to your day",
"Добрый денёчек",
"Пусть этот день будет лучше, чем вчерашний",
Expand Down Expand Up @@ -178,6 +198,13 @@ class AutomneAxioms{
"Засыпай, самая лучшая боль"
]
]
public static let specialWelcomeNarratives = [
"Welcome",
"Welcome back",
"Glad to see you",
"Hello my friend",
"Seeing you is always a pleasure"
]

public static func uniq<S : Sequence, T : Equatable>(source: S) -> [T] where S.Iterator.Element == T {
var buffer = [T]()
Expand Down
7 changes: 7 additions & 0 deletions CoreScripts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ class AutomneCore {
NSUserNotificationCenter.default.deliver(notification)
}
}
public static func displayAlert(title: String, message: String){
let alert = NSAlert()
alert.messageText = title
alert.informativeText = message
alert.addButton(withTitle: "OK")
alert.runModal()
}
}
67 changes: 51 additions & 16 deletions SFX Processor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

import Foundation
import AVFoundation
import Cocoa

class SFX {
private static var player = AVAudioPlayer()
private static let synth = AVSpeechSynthesizer()
public static var voiceIdentifier: String? = nil
private static let preferredVoices = ["ava.premium", "samantha.premium", "daniel", "alex"]

public enum Effects: String {
case powerOn = "PowOn"
case buttonClick = "Button"
Expand All @@ -30,44 +34,71 @@ class SFX {
}
}

public static func shutUp(){
public static func playSFX(sfx: String){
NSSound(named: sfx)?.play()
}

public static func shutUp(speaker: Bool = false){
player.stop()
synth.stopSpeaking(at: .immediate)
if speaker { synth.stopSpeaking(at: .immediate) }
}

public static func testVoices() {
print(AVSpeechSynthesisVoice.speechVoices())
}

public static func speak(say: String, lang: String) {
let utterance = AVSpeechUtterance(string: say)
switch lang {
case "en-US":
utterance.voice = AVSpeechSynthesisVoice(identifier: "com.apple.speech.synthesis.voice.samantha")
default:
utterance.voice = AVSpeechSynthesisVoice(language: lang)
case "en":
if voiceIdentifier == nil {
for s in preferredVoices{
let d = "com.apple.speech.synthesis.voice." + s
if AVSpeechSynthesisVoice(identifier: d) != nil {
voiceIdentifier = d
break
}
}
if voiceIdentifier == nil {
ViewController.defaults.set(0, forKey: "narrator")
AutomneCore.displayAlert(title: "No voices found", message: "Automne was unable to find any voices downloaded on this machine. Narrator will be switched off. Refer to manual in order to download a voice")
return
}
}
utterance.voice = AVSpeechSynthesisVoice(identifier: voiceIdentifier!)
default:
utterance.voice = AVSpeechSynthesisVoice(language: lang)
}

utterance.rate = 0.4
utterance.volume = 1
utterance.preUtteranceDelay = 1
utterance.volume = 0.7
utterance.postUtteranceDelay = 0.7
playSFX(sfx: "Blow")
synth.speak(utterance)
}

public static func speakWelcome(){
speak(say: AutomneAxioms.specialWelcomeNarratives.randomElement()!, lang: "en")
}

public static func composeAndSpeak(track: String, artist: String) -> Bool {
if synth.isSpeaking { return false }
let a = Int.random(in: 1...7)
let a = Int.random(in: 1...8)
if a == 1 || a == 2 {
let s = AutomneAxioms.trackNarratives.randomElement()
let d = a == 1 ? track : artist
let f = s!.0.replacingOccurrences(of: "$", with: a == 1 ? "track" : "artist")
let lang: String
if d.isLatin { lang = "en-US" }
if d.isLatin { lang = "en" }
else if d.isCyrillic { lang = "ru-RU" }
else { return false}
if s!.1 { speak(say: f, lang: "en-US") }
else { return false }
if s!.1 { speak(say: f, lang: "en") }
speak(say: d, lang: lang)
if !s!.1 { speak(say: f, lang: "en-US") }
if !s!.1 { speak(say: f, lang: "en") }
} else if a == 3 || a == 4 {
let s: String
if a == 3 {
s = AutomneAxioms.specialNarratives.randomElement()!
s = AutomneAxioms.messages.randomElement()!
} else {
let date = Date()
let calendar = Calendar.current
Expand All @@ -88,10 +119,14 @@ class SFX {
s = AutomneAxioms.specialTimeNarratives[d]!.randomElement()!
}
if s.isLatin {
speak(say: s, lang: "en-US")
} else {
speak(say: s, lang: "en")
} else if s.isCyrillic {
speak(say: s, lang: "ru-RU")
} else {
return false
}
} else {
return false
}
return true
}
Expand Down
Loading

0 comments on commit a5e8197

Please sign in to comment.