{"id":26501901,"url":"https://github.com/Goekdeniz-Guelmez/Local-NotebookLM","last_synced_at":"2025-03-20T17:03:50.017Z","repository":{"id":268950425,"uuid":"905964762","full_name":"Goekdeniz-Guelmez/Local-NotebookLM","owner":"Goekdeniz-Guelmez","description":"Googles NotebookLM but local","archived":false,"fork":false,"pushed_at":"2025-03-17T12:50:36.000Z","size":57274,"stargazers_count":143,"open_issues_count":0,"forks_count":21,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-19T20:15:19.632Z","etag":null,"topics":["anthropic-api","anthropic-claude","dl","elevenlabs-api","gemini-api","gen","groq-api","ml","notebook","openai","openai-api","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Goekdeniz-Guelmez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-19T21:47:12.000Z","updated_at":"2025-03-19T02:18:43.000Z","dependencies_parsed_at":"2024-12-19T22:45:06.689Z","dependency_job_id":"26bd520f-d573-4760-84e1-6a5568ad25f0","html_url":"https://github.com/Goekdeniz-Guelmez/Local-NotebookLM","commit_stats":null,"previous_names":["goekdeniz-guelmez/local-notebooklm"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Goekdeniz-Guelmez%2FLocal-NotebookLM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Goekdeniz-Guelmez%2FLocal-NotebookLM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Goekdeniz-Guelmez%2FLocal-NotebookLM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Goekdeniz-Guelmez%2FLocal-NotebookLM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Goekdeniz-Guelmez","download_url":"https://codeload.github.com/Goekdeniz-Guelmez/Local-NotebookLM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244656704,"owners_count":20488638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anthropic-api","anthropic-claude","dl","elevenlabs-api","gemini-api","gen","groq-api","ml","notebook","openai","openai-api","python3"],"created_at":"2025-03-20T17:02:03.915Z","updated_at":"2025-03-20T17:03:50.011Z","avatar_url":"https://github.com/Goekdeniz-Guelmez.png","language":"Python","funding_links":[],"categories":["🤖 AI, ML \u0026 Deep Learning","A01_文本生成_文本对话","Python"],"sub_categories":["大语言对话模型及数据"],"readme":"# Local-NotebookLM\n\n![logo](logo.jpeg)\n\nA local AI-powered tool that converts PDF documents into engaging podcasts, using local LLMs and TTS models.\n\n## Features\n\n- PDF text extraction and processing\n- Customizable podcast generation with different styles and lengths\n- Support for various LLM providers (OpenAI, Groq, LMStudio, Ollama, Azure)\n- Text-to-Speech conversion with voice selection\n- Fully configurable pipeline\n- Preference-based content focus\n- Programmatic API for integration in other projects\n- FastAPI server for web-based access\n- Example podcast included for demonstration\n\n## Prerequisites\n\n- Python 3.12+\n- Local LLM server (optional, for local inference)\n- Local TTS server (optional, for local audio generation)\n- At least 8GB RAM (16GB+ recommended for local models)\n- 10GB+ free disk space\n\n## Installation\n\n### From PyPI\n\n```bash\npip install local-notebooklm\n```\n\n### From source\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/Goekdeniz-Guelmez/Local-NotebookLM.git\ncd Local-NotebookLM\n```\n\n2. Create and activate a virtual environment (conda works too):\n\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows, use: venv\\Scripts\\activate\n```\n\n3. Install the required packages:\n\n```bash\npip install -r requirements.txt\n```\n## Optional pre requisites\n### Local TTS server\n- Follow one installation type (docker, docker-compose, uv) at https://github.com/remsky/Kokoro-FastAPI\n- Test in your browser that http://localhost:8880/v1 return the json: {\"detail\":\"Not Found\"}\n  \n## Example Output\n\nThe repository includes an example podcast in `examples/podcast.wav` to demonstrate the quality and format of the output. The models used are: gpt4o and Mini with tts-hs on Azure. You can listen to this example to get a sense of what Local-NotebookLM can produce before running it on your own PDFs.\n\n## Configuration\n\nYou can use the default configuration or create a custom JSON config file with the following structure:\n\n```json\n{\n    \"Co-Host-Speaker-Voice\": \"af_sky+af_bella\",\n    \"Host-Speaker-Voice\": \"af_alloy\",\n\n    \"Small-Text-Model\": {\n        \"provider\": {\n            \"name\": \"groq\",\n            \"key\": \"your-api-key\"\n        },\n        \"model\": \"llama-3.2-90b-vision-preview\"\n    },\n\n    \"Big-Text-Model\": {\n        \"provider\": {\n            \"name\": \"groq\",\n            \"key\": \"your-api-key\"\n        },\n        \"model\": \"llama-3.2-90b-vision-preview\"\n    },\n\n    \"Text-To-Speech-Model\": {\n        \"provider\": {\n            \"name\": \"custom\",\n            \"endpoint\": \"http://localhost:8880/v1\",\n            \"key\": \"not-needed\"\n        },\n        \"model\": \"kokoro\",\n        \"audio_format\": \"wav\"\n    },\n\n    \"Step1\": {\n        \"system\": \"\",\n        \"max_tokens\": 1028,\n        \"temperature\": 0.7,\n        \"chunk_size\": 1000,\n        \"max_chars\": 100000\n    },\n\n    \"Step2\": {\n        \"system\": \"\",\n        \"max_tokens\": 8126,\n        \"temperature\": 1,\n        \"chunk_token_limit\": 2000,\n        \"overlap_percent\": 10\n    },\n\n    \"Step3\": {\n        \"system\": \"\",\n        \"max_tokens\": 8126,\n        \"temperature\": 1,\n        \"chunk_token_limit\": 2000,\n        \"overlap_percent\": 20\n    }\n}\n```\n\n### Provider Options\n\nThe following provider options are supported:\n\n- **OpenAI**: Use OpenAI's API\n  ```json\n  \"provider\": {\n      \"name\": \"openai\",\n      \"key\": \"your-openai-api-key\"\n  }\n  ```\n\n- **Groq**: Use Groq's API for faster inference\n  ```json\n  \"provider\": {\n      \"name\": \"groq\",\n      \"key\": \"your-groq-api-key\"\n  }\n  ```\n\n- **Azure OpenAI**: Use Azure's OpenAI service\n  ```json\n  \"provider\": {\n      \"name\": \"azure\",\n      \"key\": \"your-azure-api-key\",\n      \"endpoint\": \"your-azure-endpoint\",\n      \"version\": \"api-version\"\n  }\n  ```\n\n- **LMStudio**: Use a local LMStudio server\n  ```json\n  \"provider\": {\n      \"name\": \"lmstudio\",\n      \"endpoint\": \"http://localhost:1234/v1\",\n      \"key\": \"not-needed\"\n  }\n  ```\n\n- **Ollama**: Use a local Ollama server\n  ```json\n  \"provider\": {\n      \"name\": \"ollama\",\n      \"endpoint\": \"http://localhost:11434\",\n      \"key\": \"not-needed\"\n  }\n  ```\n\n- **Google generative AI**: Use Google's API\n  ```json\n  \"provider\": {\n      \"name\": \"google\",\n      \"key\": \"your-google-genai-api-key\"\n  }\n  ```\n\n- **Anthropic**: Use Anthropic's API\n  ```json\n  \"provider\": {\n      \"name\": \"anthropic\",\n      \"key\": \"your-anthropic-api-key\"\n  }\n  ```\n\n- **Elevenlabs**: Use Elevenlabs's API\n  ```json\n  \"provider\": {\n      \"name\": \"elevenlabs\",\n      \"key\": \"your-elevenlabs-api-key\"\n  }\n  ```\n\n- **Custom**: Use any OpenAI-compatible API\n  ```json\n  \"provider\": {\n      \"name\": \"custom\",\n      \"endpoint\": \"your-custom-endpoint\",\n      \"key\": \"your-api-key-or-not-needed\"\n  }\n  ```\n\n## Usage\n\n### Command Line Interface\n\nRun the script with the following command:\n\n```bash\npython -m local_notebooklm.start --pdf PATH_TO_PDF [options]\n```\n\n#### Available Options\n\n| Option | Description | Default |\n|--------|-------------|---------|\n| `--pdf` | Path to the PDF file (required) | - |\n| `--config` | Path to custom config file | Uses base_config |\n| `--format` | Output format type (summary, podcast, article, interview, panel-discussion, debate, narration, storytelling, explainer, lecture, tutorial, q-and-a, news-report, executive-brief, meeting, analysis) | podcast |\n| `--length` | Content length (short, medium, long, very-long) | medium |\n| `--style` | Content style (normal, casual, formal, technical, academic, friendly, gen-z, funny) | normal |\n| `--preference` | Additional focus preferences or instructions | None |\n| `--output-dir` | Directory to store output files | ./output |\n\nLocal-NotebookLM currently does NOT support multible languages other then english, you can try working around it by adding a text in the preferences saying what language the audio should be, also be sure the TTS model supports your desired language.\n\n#### Format Types\n\nLocal-NotebookLM now supports both single-speaker and two-speaker formats:\n\n**Single-Speaker Formats:**\n- summary\n- narration\n- storytelling\n- explainer\n- lecture\n- tutorial\n- news-report\n- executive-brief\n- analysis\n\n**Two-Speaker Formats:**\n- podcast\n- interview\n- panel-discussion\n- debate\n- q-and-a\n- meeting\n\n#### Example Commands\n\nBasic usage:\n```bash\npython -m local_notebooklm.start --pdf documents/research_paper.pdf\n```\n\nCustomized podcast:\n```bash\npython -m local_notebooklm.start --pdf documents/research_paper.pdf --format podcast --length long --style casual\n```\n\nWith custom preferences:\n```bash\npython -m local_notebooklm.start --pdf documents/research_paper.pdf --preference \"Focus on practical applications and real-world examples\"\n```\n\nUsing custom config:\n```bash\npython -m local_notebooklm.start --pdf documents/research_paper.pdf --config custom_config.json --output-dir ./my_podcast\n```\n\n### Programmatic API\n\nYou can also use Local-NotebookLM programmatically in your Python code:\n\n```python\nfrom local_notebooklm.processor import podcast_processor\n\nsuccess, result = podcast_processor(\n    pdf_path=\"documents/research_paper.pdf\",\n    config_path=\"config.json\",\n    format_type=\"interview\",\n    length=\"long\",\n    style=\"professional\",\n    preference=\"Focus on the key technical aspects\",\n    output_dir=\"./test_output\"\n)\n\nif success:\n    print(f\"Successfully generated podcast: {result}\")\nelse:\n    print(f\"Failed to generate podcast: {result}\")\n```\n\n### FastAPI Server\n\nStart the FastAPI server to access the functionality via a web API:\n\n```bash\n python -m local_notebooklm.server\n```\n\nBy default, the server runs on http://localhost:8000. You can access the API documentation at http://localhost:8000/docs.\n\n## Pipeline Steps\n\n### 1. PDF Processing (Step1)\n- Extracts text from PDF documents\n- Cleans and formats the content\n- Removes irrelevant elements like page numbers and headers\n- Handles LaTeX math expressions and special characters\n- Splits content into manageable chunks for processing\n\n### 2. Transcript Generation (Step2)\n- Generates an initial podcast script based on the extracted content\n- Applies the specified style (casual, formal, technical, academic)\n- Formats content according to the desired length (short, medium, long, very-long)\n- Structures content for a conversational format\n- Incorporates user-specified format type (summary, podcast, article, interview)\n\n### 3. TTS Optimization (Step3)\n- Rewrites content specifically for better text-to-speech performance\n- Creates a two-speaker conversation format\n- Adds speech markers and natural conversation elements\n- Optimizes for natural flow and engagement\n- Incorporates user preferences for content focus\n- Formats output as a list of speaker-text tuples\n\n### 4. Audio Generation (Step4)\n- Converts the optimized text to speech using the specified TTS model\n- Applies different voices for each speaker\n- Generates individual audio segments for each dialogue part\n- Concatenates segments into a final audio file\n- Maintains consistent audio quality and sample rate\n\n### Here is a detaled diagram to visualize the architecture of my project.\n\n```mermaid\nflowchart TD\n    subgraph \"Main Controller\"\n        processor[\"podcast_processor()\"]\n    end\n\n    subgraph \"AI Services\"\n        smallAI[\"Small Text Model Client\"]\n        bigAI[\"Big Text Model Client\"]\n        ttsAI[\"Text-to-Speech Model Client\"]\n    end\n    \n    subgraph \"Step 1: PDF Processing\"\n        s1[\"step1()\"]\n        validate[\"validate_pdf()\"]\n        extract[\"extract_text_from_pdf()\"]\n        chunk1[\"create_word_bounded_chunks()\"]\n        process[\"process_chunk()\"]\n    end\n    \n    subgraph \"Step 2: Transcript Generation\"\n        s2[\"step2()\"]\n        read2[\"read_input_file()\"]\n        gen2[\"generate_transcript()\"]\n        chunk2[\"Chunking with Overlap\"]\n    end\n    \n    subgraph \"Step 3: TTS Optimization\"\n        s3[\"step3()\"]\n        read3[\"read_pickle_file()\"]\n        gen3[\"generate_rewritten_transcript()\"]\n        genOverlap[\"generate_rewritten_transcript_with_overlap()\"]\n        validate3[\"validate_transcript_format()\"]\n    end\n    \n    subgraph \"Step 4: Audio Generation\"\n        s4[\"step4()\"]\n        load4[\"load_podcast_data()\"]\n        genAudio[\"generate_speaker_audio()\"]\n        concat[\"concatenate_audio_files()\"]\n    end\n\n    %% Flow connections\n    processor --\u003e s1\n    processor --\u003e s2\n    processor --\u003e s3\n    processor --\u003e s4\n    \n    processor -.-\u003e smallAI\n    processor -.-\u003e bigAI\n    processor -.-\u003e ttsAI\n    \n    %% Step 1 flow\n    s1 --\u003e validate\n    validate --\u003e extract\n    extract --\u003e chunk1\n    chunk1 --\u003e process\n    process -.-\u003e smallAI\n    \n    %% Step 2 flow\n    s2 --\u003e read2\n    read2 --\u003e gen2\n    gen2 --\u003e chunk2\n    gen2 -.-\u003e bigAI\n    \n    %% Step 3 flow\n    s3 --\u003e read3\n    read3 --\u003e gen3\n    read3 --\u003e genOverlap\n    gen3 --\u003e validate3\n    genOverlap --\u003e validate3\n    gen3 -.-\u003e bigAI\n    genOverlap -.-\u003e bigAI\n    \n    %% Step 4 flow\n    s4 --\u003e load4\n    load4 --\u003e genAudio\n    genAudio --\u003e concat\n    genAudio -.-\u003e ttsAI\n    \n    %% Data flow\n    pdf[(\"PDF File\")] --\u003e s1\n    s1 --\u003e |\"cleaned_text.txt\"| file1[(\"Cleaned Text\")]\n    file1 --\u003e s2\n    s2 --\u003e |\"data.pkl\"| file2[(\"Transcript\")]\n    file2 --\u003e s3\n    s3 --\u003e |\"podcast_ready_data.pkl\"| file3[(\"Optimized Transcript\")]\n    file3 --\u003e s4\n    s4 --\u003e |\"podcast.wav\"| fileAudio[(\"Final Audio\")]\n\n    %% Styling\n    classDef controller fill:#f9d5e5,stroke:#333,stroke-width:2px\n    classDef ai fill:#eeeeee,stroke:#333,stroke-width:1px\n    classDef step fill:#d0e8f2,stroke:#333,stroke-width:1px\n    classDef data fill:#fcf6bd,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5\n    \n    class processor controller\n    class smallAI,bigAI,ttsAI ai\n    class s1,s2,s3,s4,validate,extract,chunk1,process,read2,gen2,chunk2,read3,gen3,genOverlap,validate3,load4,genAudio,concat step\n    class pdf,file1,file2,file3,fileAudio data\n```\n\n## Output Files\n\nThe pipeline generates the following files:\n\n- `step1/extracted_text.txt`: Raw text extracted from the PDF\n- `step1/clean_extracted_text.txt`: Cleaned and processed text\n- `step2/data.pkl`: Initial transcript data\n- `step3/podcast_ready_data.pkl`: TTS-optimized conversation data\n- `step4/segments/podcast_segment_*.wav`: Individual audio segments\n- `step4/podcast.wav`: Final concatenated podcast audio file\n\n## Troubleshooting\n\n### Common Issues\n\n1. **PDF Extraction Fails**\n   - Try a different PDF file\n   - Check if the PDF is password-protected\n   - Ensure the PDF contains extractable text (not just images)\n\n2. **API Connection Errors**\n   - Verify your API keys are correct\n   - Check your internet connection\n   - Ensure the API endpoints are accessible\n\n3. **Out of Memory Errors**\n   - Reduce the chunk size in the configuration\n   - Use a smaller model\n   - Close other memory-intensive applications\n\n4. **Audio Quality Issues**\n   - Try different TTS voices\n   - Adjust the sample rate in the configuration\n   - Check if the TTS server is running correctly\n\n### Getting Help\n\nIf you encounter issues not covered here, please:\n1. Check the logs for detailed error messages\n2. Open an issue on the GitHub repository with details about your problem\n3. Include the error message and steps to reproduce the issue\n\n## Requirements\n\n- Python 3.12+\n- PyPDF2\n- tqdm\n- numpy\n- soundfile\n- requests\n- pathlib\n- fastapi\n- uvicorn\n\nFull requirements are listed in `requirements.txt`.\n\n## Acknowledgments\n\n- This project uses various open-source libraries and models\n- Special thanks to the developers of LLaMA, OpenAI, and other AI models that make this possible\n\n---\n\nFor more information, visit the [GitHub repository](https://github.com/Goekdeniz-Guelmez/Local-NotebookLM).\n\nBest\nGökdeniz Gülmez\n\n---\n\n## Citing Local-NotebookLM\n\nThe Local-NotebookLM software suite was developed by Gökdeniz Gülmez. If you find Local-NotebookLM useful in your research and wish to cite it, please use the following\nBibTex entry:\n\n```text\n@software{\n  Local-NotebookLM,\n  author = {Gökdeniz Gülmez},\n  title = {{Local-NotebookLM}: A Local-NotebookLM to convert PDFs into Audio.},\n  url = {https://github.com/Goekdeniz-Guelmez/Local-NotebookLM},\n  version = {0.1.5},\n  year = {2025},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoekdeniz-Guelmez%2FLocal-NotebookLM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGoekdeniz-Guelmez%2FLocal-NotebookLM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoekdeniz-Guelmez%2FLocal-NotebookLM/lists"}