No deterministic rule deciding the output based on $n$ consecutive outcomes can work since these yield only binary probabilities. If rejection is allowed though, one can get every $p$. For example, to get $p=\frac13$, take two $X$ outputs, answer $1$ if they are $11$ and $0$ if they are $10$ or $01$. If they are $00$, start again with two new $X$ outputs.
The number of $X$ outputs needed to produce one bit $Y$ is unbounded but the mean number of $X$ per $Y$ output is $\frac83$, which is quite reasonable.
For every rational $p=\frac{a}b$, choose some $k$ such that $2^k\geqslant b$, consider groups of $k$ successive $X$ outputs, allocate $a$ of them to the answer $1$, $b-a$ of them to the answer $0$ and start again if you get any of the $2^k-b$ remaining ones. The mean number of $X$ outputs needed to produce one $Y$ bit is at most $2k$.
For every $p$ in $[0,1]$, a general procedure is available if one knows the binary expansion $p=0.p_1p_2p_3\ldots$ of $p$. Start producing $X$ outputs $x_1$, $x_2$, $x_3$, and so on. As soon as the numbers $p=\sum\limits_{n=1}^\infty\frac{p_n}{2^n}$ and $x=\sum\limits_{n=1}^\infty\frac{x_n}{2^n}$ can be compared, stop and answer $1$ if $x\lt p$ and $0$ otherwise. Note that the process stops almost surely after a finite number of $X$ outputs.
Exercise: Compute the mean number of $X$ outputs per $Y$ output in the general procedure (if you really do the computations, you are in for a surprise).