Convert Word Documents to Markdown for LLM / AI consumptions

I’ve finally had the time to convert preprint academic articles of JCRINN to markdowns!

Microsoft Word documents are common in research, teaching, and administration. When preparing these documents for a large language model (LLM), converting them to Markdown gives you a readable text file that you can inspect, edit, and supply to an AI application.

Pandoc is a command-line document converter available on Linux. It supports Microsoft DOCX input and several Markdown formats, making it useful for preparing manuscripts, reports, lecture notes, and technical documentation. Its focus is document structure, rather than reproducing the original page layout. Pandoc documentation

For academic writing, sections such as Introduction, Methods, Results, and Discussion provide useful boundaries. A retrieval system can divide a document at these boundaries and retrieve relevant passages when answering a question. Microsoft’s Azure AI Search documentation provides a concrete example of indexing Markdown by heading and retaining section information. This supports using Markdown as a practical format for structured retrieval. Microsoft documentation

The practical benefits include:

  • Visible input: You can review the actual text supplied to the AI application.
  • Reusable content: The same file can support summarisation, question answering, search, and a document knowledge base.
  • Source tracking: Keeping the title, authors, DOI, and source URL helps connect extracted claims to their original document.
  • Controlled selection: You can provide relevant sections instead of repeatedly submitting the complete document.

Markdown does not make an LLM automatically understand a document better or prevent invented answers. It also does not necessarily reduce token usage compared with a good DOCX text extractor. File size on disk is not a reliable measure of model input tokens. The benefit is greater control over the text and structure entering your workflow.

How to convert DOCX documents to Markdown in Ubuntu / Linux

Step 1: Install Pandoc

sudo apt install pandoc

Ubuntu’s repository version may be older than the latest upstream release. If you need a newer feature or conversion fix, consult the official Pandoc installation instructions. A LaTeX installation is unnecessary for DOCX-to-Markdown conversion.

Step 2 : Convert DOCX to Markdown (single file)

pandoc "report.docx" --from=docx --to=gfm --wrap=none -o "report.md"

For an academic manuscript with footnotes and equations, Pandoc’s own Markdown format is another useful choice:

To extract embedded images and update their references:

pandoc "report.docx" --from=docx --to=markdown --wrap=none \
  --extract-media="report-assets" -o "report.md

These formats and options are documented in the Pandoc User’s Guide. Running another example with the same output filename replaces the previous Markdown file.

An image reference does not give a text-only model access to the image’s contents. Supply figures separately to a vision-capable system, or add verified descriptions and relevant values as text.

Step 3: Review the converted document

Compare it with the Word original. Check section headings, numerical results, units, table labels, equations, references, and figure captions. Complex tables and formatting may not survive conversion accurately. Pandoc conversion limitations

For research documents, retain the qualifications attached to findings. A reported accuracy value without its dataset, evaluation method, or limitations can produce a misleading summary.

Step 4: Use the Markdown with an LLM

Upload the file to an application that accepts Markdown, or paste a relevant section into the conversation. For a larger collection, configure your retrieval workflow to preserve document identity and section headings with each passage.

A useful starting prompt is:

Using only the supplied document, identify the research objective, method, dataset, main results, and limitations. Cite the relevant section for each item. Preserve numerical values and units exactly. If information is absent, state “not reported”.

BONUS: Batch convert all DOCX files with bash

For a folder containing several documents, save the following script as batch-docx-to-markdown.sh

The script can be downloaded here in this gist: https://gist.github.com/mypapit/df6615f8611f03678bc93ee0485001be#file-batch-docx-to-markdown-sh

How to Generate Audio Spectrum Videos from MP3 songs with FFmpeg

Sometimes I need a simple way to convert an MP3 file into a video suitable for YouTube. Instead of using a static image.

I created a small Bash script that generates an animated frequency spectrum using FFmpeg.

The script uses FFmpeg’s showfreqs filter to generate an animated frequency spectrum from the audio.

How to use the script?

Step 1 : Download the script from gist

wget -c https://gist.githubusercontent.com/mypapit/37817eab6988fe05b87c64025409a894/raw/c04a917e12e9b89e6784783d19061dc771dbed99/spectrum.sh


Step 2: make it executable chmod +x spectrum.sh

Step 3: Use the script – ./spectrum.sh song.mp3

Alternatively you can also convert/export multiple mp3 files : ./spectrum.sh *.mp3

Why Use This Script?

The main advantage is simplicity. There is no video editor, GUI application, or complicated workflow involved. FFmpeg handles the audio analysis, visualization, video encoding, and audio encoding in a single operation.

It is also easy to modify the showfreqs parameters if you want different spectrum sizes, positions, frame rates, scaling methods, or visual styles.

For batch processing MP3 files into simple spectrum videos, this small Bash script provides a practical solution.

Sample Videos

Making Old DOS Games Sound Better in DOSBox-X with Shan SGM-Pro V5 SoundFont

Old DOS games are already great, but let us be honest, MIDI music can sound very rough if it is played through the default Windows MIDI synthesizer. Some games still sound okay, but many of them lose a lot of character because the instruments sound thin, cheap, or just plain boring.

This is where SoundFonts come in.

A MIDI file does not actually contain recorded music like an MP3. It is more like a set of instructions. It tells the computer which notes to play, which instruments to use, how loud they are, and when they should start or stop. The final sound depends on the synthesizer and instrument bank used to play those instructions.

A SoundFont is basically an instrument bank, usually in .sf2 or .sf3 format. It gives the MIDI synthesizer better instrument samples to work with. So instead of your DOS game music sounding like basic Windows MIDI, it can sound fuller, clearer, and more dramatic.

For this setup, I used Shan SGM-Pro V40 SoundFont. It is based around the SGM-style General MIDI sound, which is popular among retro PC gaming users because it gives many DOS game soundtracks a bigger and more modern sound. More information about Shan SGM-Pro can be found at the VOGONS thread here:

Shan SGM-Pro SoundFont on VOGONS

Why Use DOSBox-X with FluidSynth

DOSBox-X already supports MIDI configuration properly, and it can use FluidSynth to play MIDI through a SoundFont. This is cleaner than routing MIDI into another external program.

The basic idea is simple:

  1. Put the SoundFont file somewhere permanent.
  2. Tell DOSBox-X to use FluidSynth.
  3. Point DOSBox-X to the .sf2 file.
  4. Configure the old DOS game to use General MIDI, Roland Sound Canvas, or MPU-401, depending on what the game supports.

For my setup, I placed the SoundFont here:

/home/mypapit/midi/shan.sf2

You can use another folder if you want. Just make sure the path in the DOSBox-X config matches the actual file location.

DOSBox-X MIDI Configuration

# fluid.soundfont: Soundfont (.SF2 or .SF3) to use with Fluidsynth.
#                  One must be specified, for example GeneralUser_GS.sf2.

mpu401          = intelligent
mpubase         = 330
mididevice      = fluidsynth
midiconfig      =
samplerate      = 48000
mpuirq          = -1
mt32.romdir     =
mt32.model      = auto

fluid.driver    = pulseaudio
fluid.soundfont = "/home/mypapit/midi/shan.sf2"
fluid.reverb    = 20
fluid.chorus    = 16

Game Setup

After changing the DOSBox-X config, you still need to configure the DOS game itself.

In the game sound setup program, choose something like:

Music device: General MIDI
Port: 330
IRQ: 9 or default

Some games may show it as:

Roland MPU-401
Sound Canvas
General MIDI

For many DOS games from the 1990s, General MIDI is the correct choice. Examples include games like Doom, Duke Nukem 3D, Descent, Warcraft II, TIE Fighter, and many LucasArts titles.

Do not choose MT-32 unless the game soundtrack was actually made for MT-32. MT-32 and General MIDI are not the same thing. If you choose the wrong one, the music can sound strange, with incorrect instruments.

TIE-FIGHTER DEMO with SHAN SGM-PRO SoundFont

TIE Fighter is a good game to test this because its MIDI soundtrack benefits a lot from a stronger SoundFont. The music becomes more cinematic and less flat compared to the default Windows MIDI output.

Here is a YouTube video showing TIE Fighter using the Shan SGM-Pro SoundFont:

Star Wars: TIE Fighter with Shan SGM-Pro SoundFont

The difference is clear. The brass, strings, and percussion sound much heavier. It does not sound like original hardware, but that is not the goal here. The goal is to make old DOS MIDI music sound better, fuller, and more enjoyable on a modern machine.

Notes:

Keep the SoundFont file in a fixed folder. Do not put it in a temporary download folder because DOSBox-X will fail to load it if the file is moved.

Use a full path in the config file, especially on Windows.

Restart DOSBox-X after editing the config.

Make sure the game itself is configured for General MIDI or MPU-401 music output.

If there is no music, check the file path first. Most problems come from a wrong SoundFont path or a typo in the filename.

yt-dlp – a verstatile video downloader tool

yt-dlp is a command-line tool for which allows a user to download audio/video from thousands of sites. The project is a fork of youtube-dl, which is based on the now inactive youtube-dlc.

yt-dlp can be installed using official releases or via package manager.

Unix-like operating system

curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o ~/.local/bin/yt-dlp
chmod a+rx ~/.local/bin/yt-dlp  # Make executable

To update yt-dlp in Unix-like operating system

yt-dlp -U

Homebrew MacOS

brew install yt-dlp

Ubuntu

sudo add-apt-repository ppa:tomtomtom/yt-dlp # Add ppa repo to apt
sudo apt update # Update package list
sudo apt install yt-dlp # Install yt-dlp

Snap

sudo snap install --edge yt-dlp

Windows operating system

yt-dlp is also available for Windows operating system by using, winget:

winget install yt-dlp

Microsoft Windows binary package

The binary package for Microsoft Windows binary package can be downloaded from yt-dlp GitHub release page

Note that yt-dlp requires ffmpeg windows binaries which can be obtained from gyan.dev’s Codex FFMPEG Build

Please refer to this post for more information on the tips and tricks on using yt-dlp.

nmap scanning for ip camera in the network

Here’s an nmap snippet for scanning for hidden cctv / ip camera in the network

nmap -sV --script=http-enum,http-title,rtsp-url-brute -p 80,443,554,8000 <ip range>

Or you can write as :

sudo nmap -sV --script=http-enum,http-title,rtsp-url-brute -p 80,443,554,8000 192.168.0.0/24

Make sure you have permission to scan on the network!