Example 4 Given that the real number $x$ and the acute angle $\theta$ satisfy
$$
\begin{array}{l}
x^{2}+2 x \cos \theta=\sin \theta-\frac{5}{4} . \\
\text { Find the value of } \frac{x+\operatorname{tg} \theta}{x-\operatorname{tg} \theta} \text { . }
\end{array}
$$
Solution: Transposing terms, we get $x^{2}+2 x \cos \theta-\sin \theta+\frac{5}{4}=0$, which is $x^{2}+2 x \cos \theta-\sin \theta+1+\frac{1}{4}=0$.
We have $x^{2}+2 x \cos \theta-\sin \theta+\sin ^{2} \theta+\cos ^{2} \theta+\frac{1}{4}=0$,
$$
(x+\cos \theta)^{2}+\left(\sin \theta-\frac{1}{2}\right)^{2}=0
$$

Thus, $x+\cos \theta=0, \sin \theta-\frac{1}{2}=0$.
That is, $x=-\cos \theta, \sin \theta=\frac{1}{2}$.
$\because \theta$ is an acute angle,
$$
\therefore \theta=30^{\circ}, x=-\frac{\sqrt{3}}{2} \text {. }
$$

Therefore, the original expression $=\frac{1}{5}$.