This sort of problem requires a state-machine. Various events and time-outs are used to trigger transistions between states.
Here you have states like idle, dot_or_dash, dash.
When a beep starts you want to transition idle -> dot_or_dash and record the time.
When in dot_or_dash state and the time since entering the state goes over the threshold you transistion
to dash state. Beep ending transitions dot_or_dash to idle and emits a dot. Beep ending transistions dash state to idle and emits a dash.
You'll need a few more states for recognizing word gaps.