diff --git a/AI.YouTubeSummarizer/AI.YouTubeSummarizer.csproj b/AI.YouTubeSummarizer/AI.YouTubeSummarizer.csproj index c8e7239..1f4c9de 100644 --- a/AI.YouTubeSummarizer/AI.YouTubeSummarizer.csproj +++ b/AI.YouTubeSummarizer/AI.YouTubeSummarizer.csproj @@ -1,6 +1,7 @@  Exe + 0.1.0 net6.0 AI.YouTubeSummarizer enable @@ -8,7 +9,6 @@ a746658a-2ee0-448d-b156-5916b1b2d051 true true - win-x64 diff --git a/AI.YouTubeSummarizer/ConfigurationSettings.cs b/AI.YouTubeSummarizer/ConfigurationSettings.cs index 60c2e1d..dfc6b9d 100644 --- a/AI.YouTubeSummarizer/ConfigurationSettings.cs +++ b/AI.YouTubeSummarizer/ConfigurationSettings.cs @@ -9,17 +9,5 @@ public class ConfigurationSettings public string OPENAI_KEY { get; set; } [JsonPropertyName("languages")] - public IReadOnlyList Languages { get; set; } -} - -public class LanguageConfig -{ - [JsonPropertyName("alias")] - public string Alias { get; set; } - - [JsonPropertyName("description")] - public string Description { get; set; } - - [JsonPropertyName("prompt")] - public string Prompt { get; set; } + public IReadOnlyList Languages { get; set; } } diff --git a/AI.YouTubeSummarizer/Program.cs b/AI.YouTubeSummarizer/Program.cs index 69ed961..affc1a8 100644 --- a/AI.YouTubeSummarizer/Program.cs +++ b/AI.YouTubeSummarizer/Program.cs @@ -51,7 +51,7 @@ private static ConfigurationSettings ConfigureSettings() { var builder = new ConfigurationBuilder() .AddUserSecrets() - .AddJsonFile("config.json", optional: false, reloadOnChange: true) + .AddJsonFile("config.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); var configuration = builder.Build(); diff --git a/AI.YouTubeSummarizer/YouTubeSummarizer.cs b/AI.YouTubeSummarizer/YouTubeSummarizer.cs index b8c7b93..4627514 100644 --- a/AI.YouTubeSummarizer/YouTubeSummarizer.cs +++ b/AI.YouTubeSummarizer/YouTubeSummarizer.cs @@ -15,7 +15,7 @@ public class YouTubeSummarizer private double _lastStartTime; private TranscriptItem _lastItem; private string _videoTitle; - private LanguageConfig _selectedLanguage; + private string _selectedLanguage; public YouTubeSummarizer(ConfigurationSettings configData) { @@ -40,7 +40,7 @@ public async Task SummarizeVideoAsync(string youTubeUrl) --------------------------------------------------"); IChatCompletion chatCompletion = new OpenAIChatCompletion("gpt-3.5-turbo", this._configData.OPENAI_KEY); - var chat = (OpenAIChatHistory)chatCompletion.CreateNewChat(this._selectedLanguage.Prompt); + var chat = (OpenAIChatHistory)chatCompletion.CreateNewChat("You are a summarizer, I will provide you any language truncated text and you are going to summarize it for me in " + this._selectedLanguage); if (this._transcriptItems.Count > 0) { @@ -62,7 +62,7 @@ private void FetchTranscriptItems(string videoId) TranscriptList transcriptResult = youTubeTranscriptApi.ListTranscripts(videoId); this._videoTitle = transcriptResult.VideoTitle; - foreach (var item in transcriptResult.FindTranscriptOrDefaultToExisting("en", "pt").Fetch()) + foreach (var item in transcriptResult.FindTranscriptOrDefaultToExisting("en").Fetch()) { this._transcriptItems.Enqueue(item); } @@ -140,12 +140,7 @@ internal void PromptForLanguages() if (this._configData.Languages is null || this._configData.Languages.Count == 0) { Console.WriteLine("⚠️ No language configuration detected.\n\nDefaulting to English.\n"); - this._selectedLanguage = new LanguageConfig - { - Alias = "en", - Description = "English", - Prompt = "You are a summarizer, every text I provide you are going to summarize it for me" - }; + this._selectedLanguage = "English"; return; } @@ -155,7 +150,7 @@ internal void PromptForLanguages() Console.WriteLine("Please select the language you want to use for the summarization: "); for (int i = 0; i < this._configData.Languages.Count; i++) { - Console.WriteLine($"{i + 1} - {this._configData.Languages[i].Description}"); + Console.WriteLine($"{i + 1} - {this._configData.Languages[i]}"); } Console.Write("Option: "); @@ -168,7 +163,7 @@ internal void PromptForLanguages() { this._selectedLanguage = this._configData.Languages[optionNumber - 1]; - Console.WriteLine($"\nSelected language: {this._selectedLanguage.Description}\n"); + Console.WriteLine($"\nSelected language: {this._selectedLanguage}\n"); return; } } @@ -178,7 +173,7 @@ internal void PromptForLanguages() } this._selectedLanguage = this._configData.Languages[0]; - Console.WriteLine($"ℹ️ Only one language configuration detected.\n\nAuto-Selected language: {this._selectedLanguage.Description}\n"); + Console.WriteLine($"ℹ️ Only one language configuration detected.\n\nAuto-Selected language: {this._selectedLanguage}\n"); return; } } diff --git a/AI.YouTubeSummarizer/config.json b/AI.YouTubeSummarizer/config.json index 88ec9db..483c236 100644 --- a/AI.YouTubeSummarizer/config.json +++ b/AI.YouTubeSummarizer/config.json @@ -1,19 +1,3 @@ { - "languages": [ - { - "alias": "en", - "description": "English", - "prompt": "You are a summarizer, I will provide you any language truncated text and you are going to summarize it for me in English" - }, - { - "alias": "pt", - "description": "Português", - "prompt": "You are a summarizer, I will provide you any language truncated text and you are going to summarize it for me in Portuguese" - }, - { - "alias": "kr", - "description": "한국어", - "prompt": "You are a summarizer, I will provide you any language truncated text and you are going to summarize it for me in Korean" - } - ] + "languages": ["English", "Português", "한국어"] } \ No newline at end of file diff --git a/README.md b/README.md index 2349029..e45c26b 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,23 @@ Summarize your Youtube Videos quickly using your preferred language. -## End user - Installation +## End user - Setup Get the released version executable. Here: -1. Setup your OpenAI API Key +##### Setup your OpenAI API Key - Create an environment variable named `OPENAI_KEY` with your OpenAI API Key. +Create an environment variable named `OPENAI_KEY` with your OpenAI API Key. + +##### Optionally you can use your own preferred languages to summarize + +Change `config.json` file with your preferred languages and leave it in the same folder as the application. + +```json +{ + "languages": ["English", "Your Language 1", "Your Language 2", ...] +} +``` ## Developer Setup @@ -27,7 +37,7 @@ dotnet user-secrets init dotnet user-secrets set "OPENAI_KEY" "" ``` -### Running / Development +Running / Debugging ```powershell dotnet run @@ -35,8 +45,16 @@ dotnet run ### Deploying / Publishing +Windows: + +```powershell +dotnet publish -r win-x64 -c Release +``` + +Linux: + ```powershell -dotnet publish -c Release +dotnet publish -r linux-x64 -c Release -p:PublishReadyToRun=true ``` ## Projects Used