Suppose I have a finitely presented group $G$. By this, I mean I know explicitly what $S$ and $R$ are such that $G = \langle S \mid R \rangle$. Suppose I have a subgroup generated by a finite set of words $W$ (that is, $H = \langle W \rangle \leq G$) and I also know all the elements of $W$ explicitly.

Is there an algorithm that gives me the index $[G:H]$? Or at least tells me whether it is finite or not?