From BIP341:
A Taproot output is a native SegWit output (see BIP141) with version
number 1, and a 32-byte witness program. [...]
- Let q be the 32-byte array containing the witness program (the second push in the scriptPubKey) which represents a public key
according to BIP340.
- Fail if the witness stack has 0 elements.
- If there are at least two witness elements, and the first byte of the last element is 0x50, this last element is called annex a
and is removed from the witness stack. The annex (or the lack of
thereof) is always covered by the signature and contributes to
transaction weight, but is otherwise ignored during taproot
validation.
- If there is exactly one element left in the witness stack, key path spending is used:
- The single witness stack element is interpreted as the signature and must be valid (see the next section) for the public key
q (see the next subsection).
- If there are at least two witness elements left, script path spending is used:
- Call the second-to-last stack element s, the script.
In other words, Taproot key path spends only have one1 witness item, the signature. Script path spends always have at least two witness items, and usually more to provide an initial stack for the script execution.
Since BIP340 signatures don't allow public key recovery, you can't compute the public key (and therefore address) from the signature alone in a key path spend. In a script path spend, you could combine the revealed internal key with the root of the script to get the public key.
However, getting the output script of the output being spent is as simple as looking up the transaction output referenced by the txid and index in the input, so there's rarely a reason to use a method that only works for some output scripts, and requires you to know the output type (P2TR in this case) in the first place.
1 Assuming the annex is not present.
witness fields
orwitness data
.